Home |
Search |
Today's Posts |
#1
Posted to microsoft.public.excel.programming
|
|||
|
|||
VBA Code for IF B1 < "" then C1="FILLED"
I have a column that has a random number of entries in it (sometimes cell
B1-B20 are filled sometimes B1-B4 are filled, etc). I am looking to write a macro that when run, will check to see if there is a value in column B, and if so, fill the corresponding cell in Column C with "FILLED" |
#2
Posted to microsoft.public.excel.programming
|
|||
|
|||
VBA Code for IF B1 < "" then C1="FILLED"
Hi Diane
You don't say how Column B gets it's data. Could you not simply use the IF function in column c =IF(B1<"", "Filled",""). Nick "Diane" wrote in message ... I have a column that has a random number of entries in it (sometimes cell B1-B20 are filled sometimes B1-B4 are filled, etc). I am looking to write a macro that when run, will check to see if there is a value in column B, and if so, fill the corresponding cell in Column C with "FILLED" |
#3
Posted to microsoft.public.excel.programming
|
|||
|
|||
VBA Code for IF B1 < "" then C1="FILLED"
How about:
Range("b1").Select Do Until ActiveCell.Value = "" ActiveCell.Offset(0, 1).Value = "Filled" ActiveCell.Offset(1, 0).Select Loop HTH "Diane" wrote: I have a column that has a random number of entries in it (sometimes cell B1-B20 are filled sometimes B1-B4 are filled, etc). I am looking to write a macro that when run, will check to see if there is a value in column B, and if so, fill the corresponding cell in Column C with "FILLED" |
#4
Posted to microsoft.public.excel.programming
|
|||
|
|||
VBA Code for IF B1 < "" then C1="FILLED"
Dim iLastRow As Long
Dim i As Long iLastRow = Cells(Rows.Count, "B").End(xlUp).Row For i = 1 To iLastRow If Cells(i, "B").Value < "" Then Cells(i, "C").Value = "FILLED" End If Next i -- HTH Bob Phillips "Diane" wrote in message ... I have a column that has a random number of entries in it (sometimes cell B1-B20 are filled sometimes B1-B4 are filled, etc). I am looking to write a macro that when run, will check to see if there is a value in column B, and if so, fill the corresponding cell in Column C with "FILLED" |
#5
Posted to microsoft.public.excel.programming
|
|||
|
|||
VBA Code for IF B1 < "" then C1="FILLED"
As long as you fill data sequentially (i.e., no holes) and you have at
least one entry (i.e., B1 is not empty), a loop-less solution: Option Explicit Sub testit() With ActiveSheet Range(.Range("b1"), .Cells(.Rows.Count, 2).End(xlUp)) _ .Offset(0, 1).Value = "filled" End With End Sub For more see example 4 in Beyond Excel's recorder http://www.tushar- mehta.com/excel/vba/beyond_the_macro_recorder/index.htm -- Regards, Tushar Mehta www.tushar-mehta.com Excel, PowerPoint, and VBA add-ins, tutorials Custom MS Office productivity solutions In article , says... I have a column that has a random number of entries in it (sometimes cell B1-B20 are filled sometimes B1-B4 are filled, etc). I am looking to write a macro that when run, will check to see if there is a value in column B, and if so, fill the corresponding cell in Column C with "FILLED" |
#6
Posted to microsoft.public.excel.programming
|
|||
|
|||
VBA Code for IF B1 < "" then C1="FILLED"
Thank you all - very helpful!!!!
"Bob Phillips" wrote: Dim iLastRow As Long Dim i As Long iLastRow = Cells(Rows.Count, "B").End(xlUp).Row For i = 1 To iLastRow If Cells(i, "B").Value < "" Then Cells(i, "C").Value = "FILLED" End If Next i -- HTH Bob Phillips "Diane" wrote in message ... I have a column that has a random number of entries in it (sometimes cell B1-B20 are filled sometimes B1-B4 are filled, etc). I am looking to write a macro that when run, will check to see if there is a value in column B, and if so, fill the corresponding cell in Column C with "FILLED" |
Reply |
Thread Tools | Search this Thread |
Display Modes | |
|
|
Similar Threads | ||||
Thread | Forum | |||
Excel - Golf - how to display "-2" as "2 Under" or "4"as "+4" or "4 Over" in a calculation cell | Excel Discussion (Misc queries) | |||
change "true" and "false" to "availble" and "out of stock" | Excel Worksheet Functions | |||
HELP on "left","right","find","len","substitute" functions | Excel Discussion (Misc queries) | |||
Count occurences of "1"/"0" (or"TRUE"/"FALSE") in a row w. conditions in the next | New Users to Excel | |||
Looking for VB code to test for "RING" , "BUSY" disconnects or other signals | Excel Programming |