Fill numbers after that search character.

Kishan

Well-known Member
Joined
Mar 15, 2011
Messages
1,648
Office Version
  1. 2010
Platform
  1. Windows
Using Excel 2000

Hi,

Data are the numbers shown in the cells E6:E15, which I want, could be filled in column D,

Part1-counting the cell down to D6, if D6 = 0 than 5 will be filled in cell D10 counting to down 12 will be filled in cell D22 and so on for rest of the numbers are in E6:E15...

Part-2- this is bit awkward where each number is filled in the column D I want to be filled below that number character from the next row of column C
For example if 5 is filled in cell D10 so it find character in column c from the next row and place it below the number 5 in cell D11 and so on...

Data example...


Book1
ABCDEF
1
2
3
4
5C1Insert Row n & CharData
6X5
7X12
8X11
924
10155
11XX5
12X7
1316
1413
15114
16X
171
181
19X
201
211
22212
2311
24X
251
26X
271
281
291
301
311
321
33211
3411
352
361
37X
38X4
39XX
401
41X
422
43X
44X5
4511
461
472
481
49X
50X5
51XX
52X
53X
542
55X
561
57X7
5811
591
602
61X
622
631
6416
6511
66X
67X3
6811
69X
701
711
721
731
741
751
761
772
781
791
801
812
82214
83XX
841
85X
861
871
881
89
Sheet1


Thank you in advance

Regards,
Kishan
 

Excel Facts

Difference between two dates
Secret function! Use =DATEDIF(A2,B2,"Y")&" years"&=DATEDIF(A2,B2,"YM")&" months"&=DATEDIF(A2,B2,"MD")&" days"
Re: Bit awkward fill numbers after that search character.

Your description and your sample don't seem to match. According to your description the 4 should be in row 37 (33+4) but you have it in row 38. Assuming that you made a mistake filling out your table then you can use this macro:

Code:
Public Sub BitAwkwardFill()

Dim lastRow As Long
Dim thisRow As Long
Dim nextRow As Long

lastRow = Cells(Rows.Count, 5).End(xlUp).Row
nextRow = 5
For thisRow = 6 To lastRow
    nextRow = nextRow + Cells(thisRow, 5).Value
    Cells(nextRow, 4).Value = Cells(thisRow, 5).Value
    Cells(nextRow + 1, 4).Value = Cells(nextRow + 1, 3).Value
Next thisRow

End Sub

WBD
 
Upvote 0
Re: Bit awkward fill numbers after that search character.

ABCDEF
1
2
3
4
5C1Insert Row nº & CharData
6X51011
7X122223
8X113334
9243738
101554243
11XX54748
12X75455
13166061
14136364
151147778
16X
171
181
19X
201
211
22212for j = 7 to 16
2311cells(cells(j,8),5)=cells(j,6)
24Xcells(cells(j,8)+1,5)=cells(cells(j,8)+1,4
251next j
26X
271
281not tested but the 2 helper columns make it really simple
291
301
311
321
33211
3411
352
361
37X
38X4
39XX
401
41X
422
43X
44X5
4511

<colgroup><col span="3"><col><col><col><col span="9"></colgroup><tbody>
</tbody>
 
Upvote 0
Re: Bit awkward fill numbers after that search character.

Your description and your sample don't seem to match. According to your description the 4 should be in row 37 (33+4) but you have it in row 38. Assuming that you made a mistake filling out your table then you can use this macro:

Code:
Public Sub BitAwkwardFill()

Dim lastRow As Long
Dim thisRow As Long
Dim nextRow As Long

lastRow = Cells(Rows.Count, 5).End(xlUp).Row
nextRow = 5
For thisRow = 6 To lastRow
    nextRow = nextRow + Cells(thisRow, 5).Value
    Cells(nextRow, 4).Value = Cells(thisRow, 5).Value
    Cells(nextRow + 1, 4).Value = Cells(nextRow + 1, 3).Value
Next thisRow

End Sub

WBD
Amazing!! wideboydixon, I just noticed that being a mistaken in D37 all the down way is incorrect. Sorry for the incontinence.

Your code is resulting without any error and giving the result, as it should be.

I appreciate a lot your help

Kind regards,
Kishan :)
 
Upvote 0
Re: Bit awkward fill numbers after that search character.

not tested but the 2 helper columns make it really simple
Hi oldbrewer, thank you for your help please could you tell me how this work I could not find the way

Kind regards,
Kishan
 
Upvote 0
Re: Bit awkward fill numbers after that search character.

you paste those 4 lines of code into a macro - tools, record macro, select A1, stop macro

then tools macro edit macro, and delete only the line range(A1).select and paste in my 4 lines of code
 
Upvote 0
Re: Bit awkward fill numbers after that search character.

you paste those 4 lines of code into a macro - tools, record macro, select A1, stop macro

then tools macro edit macro, and delete only the line range(A1).select and paste in my 4 lines of code
Hi oldbrewer, thank you for guiding got it work.

Kind regards,
Kishan :)


 
Upvote 0

Forum statistics

Threads
1,216,024
Messages
6,128,333
Members
449,443
Latest member
Chrissy_M

We've detected that you are using an adblocker.

We have a great community of people providing Excel help here, but the hosting costs are enormous. You can help keep this site running by allowing ads on MrExcel.com.
Allow Ads at MrExcel

Which adblocker are you using?

Disable AdBlock

Follow these easy steps to disable AdBlock

1)Click on the icon in the browser’s toolbar.
2)Click on the icon in the browser’s toolbar.
2)Click on the "Pause on this site" option.
Go back

Disable AdBlock Plus

Follow these easy steps to disable AdBlock Plus

1)Click on the icon in the browser’s toolbar.
2)Click on the toggle to disable it for "mrexcel.com".
Go back

Disable uBlock Origin

Follow these easy steps to disable uBlock Origin

1)Click on the icon in the browser’s toolbar.
2)Click on the "Power" button.
3)Click on the "Refresh" button.
Go back

Disable uBlock

Follow these easy steps to disable uBlock

1)Click on the icon in the browser’s toolbar.
2)Click on the "Power" button.
3)Click on the "Refresh" button.
Go back
Back
Top