Reply
 
LinkBack Thread Tools Search this Thread Display Modes
  #1   Report Post  
Posted to microsoft.public.excel.programming
external usenet poster
 
Posts: 96
Default 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   Report Post  
Posted to microsoft.public.excel.programming
external usenet poster
 
Posts: 20
Default 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   Report Post  
Posted to microsoft.public.excel.programming
external usenet poster
 
Posts: 27
Default 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   Report Post  
Posted to microsoft.public.excel.programming
external usenet poster
 
Posts: 1,120
Default 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   Report Post  
Posted to microsoft.public.excel.programming
external usenet poster
 
Posts: 1,071
Default 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   Report Post  
Posted to microsoft.public.excel.programming
external usenet poster
 
Posts: 96
Default 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
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
Excel - Golf - how to display "-2" as "2 Under" or "4"as "+4" or "4 Over" in a calculation cell Steve Kay Excel Discussion (Misc queries) 2 August 8th 08 01:54 AM
change "true" and "false" to "availble" and "out of stock" inthestands Excel Worksheet Functions 2 July 19th 07 07:05 PM
HELP on "left","right","find","len","substitute" functions serene83 Excel Discussion (Misc queries) 5 June 27th 06 02:23 AM
Count occurences of "1"/"0" (or"TRUE"/"FALSE") in a row w. conditions in the next BCB New Users to Excel 7 May 13th 06 10:02 PM
Looking for VB code to test for "RING" , "BUSY" disconnects or other signals BruceJ[_2_] Excel Programming 3 November 20th 03 01:55 AM


All times are GMT +1. The time now is 07:29 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"