Reply
 
LinkBack Thread Tools Search this Thread Display Modes
  #1   Report Post  
Posted to microsoft.public.excel.programming
external usenet poster
 
Posts: 5
Default Need to fill a column if the column next to it is not blank

Hello,

I don't know much about VBA and Excel 2007 but am working my way
through it slowly.

Basically, I have two columns. A contains several rows of data, and B
is currently empty. Where A is not empty, I want to put a "1" in
column B.

I don't know the best way to do this. I was thinking about selecting
the row and doing some kind of autofill, but that doesn't check the
row next to it. So I suppose I could do something like

Dim i as integer
Set i = 1
Do until i = 1000 'there will never be more than 1000 rows..
If Ai is not blank Then
Bi = 1
End If
Next i


Not really sure how to do that in VBA though!
  #2   Report Post  
Posted to microsoft.public.excel.programming
external usenet poster
 
Posts: 1
Default Need to fill a column if the column next to it is not blank

Try something like this:

Dim rng as Range, c as Range

Set rng = Range("A1:A10") 'adjust as needed for your own needs
For Each c in rng.Cells
if c.Value = "" then c.Offset(0, 1).Value = 1
Next c

HTH


"cqmman" wrote in message
...
Hello,

I don't know much about VBA and Excel 2007 but am working my way
through it slowly.

Basically, I have two columns. A contains several rows of data, and B
is currently empty. Where A is not empty, I want to put a "1" in
column B.

I don't know the best way to do this. I was thinking about selecting
the row and doing some kind of autofill, but that doesn't check the
row next to it. So I suppose I could do something like

Dim i as integer
Set i = 1
Do until i = 1000 'there will never be more than 1000 rows..
If Ai is not blank Then
Bi = 1
End If
Next i


Not really sure how to do that in VBA though!



  #3   Report Post  
Posted to microsoft.public.excel.programming
external usenet poster
 
Posts: 5
Default Need to fill a column if the column next to it is not blank

On 15 May, 22:32, "Spicelon" wrote:
Try something like this:

Dim rng as Range, c as Range

Set rng = Range("A1:A10") * * 'adjust as needed for your own needs
For Each c in rng.Cells
* * if c.Value = "" then c.Offset(0, 1).Value = 1
Next c

HTH



Thanks, that is great!
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
Auto-update Fill Series in column that has randomly spaced blank c Khind Excel Discussion (Misc queries) 3 February 5th 10 06:00 PM
fill blank cells in a column Luís Miguel Ramires Vieira Reis RAM Excel Worksheet Functions 1 November 18th 08 01:06 PM
Fill column blanks from last non-blank cell C. BROWN Excel Discussion (Misc queries) 2 August 28th 06 08:36 PM
Help: How do I fill a column with values if it is blank? limshady411[_3_] Excel Programming 4 November 14th 05 09:55 AM
how can i fill blank cells in column with abc while the right col. khurram saddique Excel Discussion (Misc queries) 2 February 12th 05 03:25 PM


All times are GMT +1. The time now is 02:03 AM.

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"