View Single Post
  #1   Report Post  
Posted to microsoft.public.excel.programming
Jacob Skaria Jacob Skaria is offline
external usenet poster
 
Posts: 8,520
Default If cell is not null, add value to adjecent cell

The below macro checks for data in Column A and if found fills Column B with
"Hello" and loops until it reaches a null cell. If you are new to macros set
the Security level to low/medium in (Tools|Macro|Security). 'Launch VBE using
short-key Alt+F11. Insert a module and paste the below code. Save. Get back
to Workbook. Tools|Macro|Run Macro1()

Sub Macro1()
Dim lngRow
lngRow = 1
Do While Trim(Range("A" & lngRow)) < ""
If Range("A" & lngRow) < "" Then Range("B" & lngRow) = "Hello"
lngRow = lngRow + 1
Loop
End Sub


If this post helps click Yes
---------------
Jacob Skaria


"Maver1ck666" wrote:

Hi all,

I have a spreadsheet which is automatically inported form a text file by VBA
by the click of a button

What I am trying to achieve (but failing miserably) is to build a loop
statement that says, if cell x1 is not null then y1 = "hello!". This would
then move on to x2 etc until it reaches a null cell which would then exit the
sub.

The tab will have mulitple records and I just cant seem to figure out the
best (and quickest) automated way of doing it.

Cheers for your help!

Mav