Reply
 
LinkBack Thread Tools Search this Thread Display Modes
  #1   Report Post  
Posted to microsoft.public.excel.programming
external usenet poster
 
Posts: 34
Default If cell is not null, add value to adjecent cell

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
  #2   Report Post  
Posted to microsoft.public.excel.programming
external usenet poster
 
Posts: 3,101
Default If cell is not null, add value to adjecent cell

Sub changeValues()
Const NULLCOLUMNTOCHECK As String = "A"

Dim iStartingRow As Long
Dim iLastRow As Long

iLastRow = Range(NULLCOLUMNTOCHECK & Rows.Count).End(xlUp).Row
For iStartingRow = 2 To iLastRow
If Range(NULLCOLUMNTOCHECK & iStartingRow).Value < "" Then
Range(NULLCOLUMNTOCHECK & iStartingRow).Offset(0, 1).Value = "HELLO"
Else
Range(NULLCOLUMNTOCHECK & iStartingRow).Offset(0, 1).Value = "GOODBYE"
End If
Next
End Sub

"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

Reply
Thread Tools Search this Thread
Search this Thread:

Advanced Search
Display Modes

Posting Rules

Smilies are On
[IMG] code is On
HTML code is Off
Trackbacks are On
Pingbacks are On
Refbacks are On


Similar Threads
Thread Thread Starter Forum Replies Last Post
Set cell value if adjecent cell value is greater than 0 SaigonJeff Excel Worksheet Functions 2 June 1st 09 12:41 PM
If cell is not null, add value to adjecent cell Jacob Skaria Excel Programming 0 April 14th 09 06:12 PM
Change Validation list in the adjecent cell on the Basis of Value in the Current Cell ankur Excel Programming 1 January 10th 07 12:56 AM
cell value based on null/not null in another cell spence Excel Worksheet Functions 1 February 18th 06 11:49 PM
cell shows 0 when referenced cell is null dee Excel Worksheet Functions 8 October 6th 05 01:39 PM


All times are GMT +1. The time now is 01:33 PM.

Powered by vBulletin® Copyright ©2000 - 2024, Jelsoft Enterprises Ltd.
Copyright ©2004-2024 ExcelBanter.
The comments are property of their posters.
 

About Us

"It's about Microsoft Excel"