Home |
Search |
Today's Posts |
#1
Posted to microsoft.public.excel.programming
|
|||
|
|||
Easy VBA question: range control
I know this sounds easy, but I'm new to VBA and I haven't been able to solve
it successfully: In a VBA IF-THEN-ELSE statement, how do I specify a range that includes column A from cell A2 to the last non-empty column? Here's my existing code: Sub aaaa Column ("A:A").Select For Each cell in Selection If cell.Value 0 Then cell.Offset(0, 1) = "string1" Else cell.Offset(0, 1) = "string2" End If Next Cell End Sub This code works, but fills the entire Offset column, all 65,000+ rows. I only want to to fill the first 1000-1500 rows, depending on how many rows in the worksheet have data. Thanks in advance. -jbb |
#2
Posted to microsoft.public.excel.programming
|
|||
|
|||
Easy VBA question: range control
Saaawwwwry.... that should read "last non-empty cell".
|
#3
Posted to microsoft.public.excel.programming
|
|||
|
|||
Easy VBA question: range control
Sub aaaa
Dim cell as Range, rng as Range set rng = Range(cells(1,1),Cells(rows.count,1).End(xlup)) For Each cell in rng If cell.Value 0 Then cell.Offset(0, 1) = "string1" Else cell.Offset(0, 1) = "string2" End If Next Cell End Sub -- Regards, Tom Ogilvy "J.B. Bobbitt" wrote in message nk.net... Saaawwwwry.... that should read "last non-empty cell". |
#4
Posted to microsoft.public.excel.programming
|
|||
|
|||
Easy VBA question: range control
This group is too cool! I hope I can be of some help.
Thanks. -jbb "Tom Ogilvy" wrote in message ... Sub aaaa Dim cell as Range, rng as Range set rng = Range(cells(1,1),Cells(rows.count,1).End(xlup)) For Each cell in rng If cell.Value 0 Then cell.Offset(0, 1) = "string1" Else cell.Offset(0, 1) = "string2" End If Next Cell End Sub -- Regards, Tom Ogilvy "J.B. Bobbitt" wrote in message nk.net... Saaawwwwry.... that should read "last non-empty cell". |
Reply |
Thread Tools | Search this Thread |
Display Modes | |
|
|
Similar Threads | ||||
Thread | Forum | |||
Hopefully an easy question | Excel Worksheet Functions | |||
*EASY* question 2!! | New Users to Excel | |||
*EASY* question! | New Users to Excel | |||
new user with easy question? not easy for me | New Users to Excel | |||
MultiPage control: Easy question | Excel Programming |