Select column range in VB?

  • Thread starter Thread starter Alan
  • Start date Start date
A

Alan

Hi - I am using MS XL 2002 and I have created a macro that inputs data
to a specific cell. I want the macro to input this data in a range of
cells; the data should be input into all the same row cells in column
A, providing there is data in the same rows in Column B.

For example, it should look at column B, realize that there is data in
all cells B2:B121 and input the data into cells A2:A121 I am not
concerned with the inputting of the data, it is specifying the range of
cells to be affected that I am having trouble with.

Hope that is clear enough......

Thanks!

Alan
 
Sub demo()
Dim r As Range, rr As Range
v = 123.456
Set r = Range("A:A")
For Each rr In r

If IsEmpty(rr.Offset(0, 1)) Then
Else
rr.Value = v
End If
Next
End Sub

This little routine travels down column A putting in a value if the neighbor
in column B is not empty.
 
Thank you so much for the help! I plugged it in and voila' - works
great!

- Alan
 

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

Back
Top