vba code for finding the ranges between 2 cols

T

tom

I have 2 columns A,B with values; i have to list out the values between A1,B1
including A1, B1 after that it should move to row2.....so on.I have to get
the answer the which is mentioned in C column. Please suggest. I tried but
inner loop is not working for me.

A B C

4 7 5
9 11 6
19 21 7
53 59 9
61 65 10
11
19
20
21
53
54
59
61
62
63
64
65
 
J

Joel

Sub GetNumbers()

RowCount = 1
NewRow = 1
Do While Range("A" & RowCount) <> ""
FirstNum = Range("A" & RowCount)
LastNum = Range("B" & RowCount)
For i = FirstNum To LastNum
Range("C" & NewRow) = i
NewRow = NewRow + 1
Next i
RowCount = RowCount + 1
Loop


End Sub
 
T

tom

The below coding working fine but if b1 is blank in this case c1 should
display A1 like below.Please suggest.

A1 B1 C1

19 20 19
25 20
25
 
P

Patrick Molloy

add the indicated line:


tom said:
The below coding working fine but if b1 is blank in this case c1 should
display A1 like below.Please suggest.

A1 B1 C1

19 20 19
25 20
25
 

Ask a Question

Want to reply to this thread or ask your own question?

You'll need to choose a username for the site, which only take a couple of moments. After that, you can post your question and our members will help you out.

Ask a Question

Top