#1   Report Post  
Posted to microsoft.public.excel.misc
pm pm is offline
external usenet poster
 
Posts: 122
Default macro help please!

I am trying to read the column below, and if a cell is blank, I want to
populate it with a number and increment each subsequent blank after that.
Thanks.


Memo
BAG# 9843 LOCATION# 0000000016
BAG# 1075 LOCATION# 0000000018
BAG# 9841 LOCATION# 0000000016

BAG# 7992 LOCATION# 0000000026
BAG# 9845 LOCATION# 0000000016
BAG# 7990 LOCATION# 0000000026
BAG# 2625 LOCATION# 0000000071
BAG# 1077 LOCATION# 0000000018
BAG# 0136 LOCATION# 0000000061
BAG# 0067 LOCATION# 0000000061

BAG# 0391 LOCATION# 0000000062

  #2   Report Post  
Posted to microsoft.public.excel.misc
external usenet poster
 
Posts: 461
Default macro help please!

You need to create a loop that says something like

Dim x as Integer

x = 1

Do Until '''put what you want here

If ActiveCell.Value = "" Then
ActiveCell.Value = x
x = x + 1
End If

ActiveCell.Offset(1,0).Activate

Loop


"pm" wrote:

I am trying to read the column below, and if a cell is blank, I want to
populate it with a number and increment each subsequent blank after that.
Thanks.


Memo
BAG# 9843 LOCATION# 0000000016
BAG# 1075 LOCATION# 0000000018
BAG# 9841 LOCATION# 0000000016

BAG# 7992 LOCATION# 0000000026
BAG# 9845 LOCATION# 0000000016
BAG# 7990 LOCATION# 0000000026
BAG# 2625 LOCATION# 0000000071
BAG# 1077 LOCATION# 0000000018
BAG# 0136 LOCATION# 0000000061
BAG# 0067 LOCATION# 0000000061

BAG# 0391 LOCATION# 0000000062

  #3   Report Post  
Posted to microsoft.public.excel.misc
external usenet poster
 
Posts: 1,071
Default macro help please!


This little macro will do that. I assumed your data is in Column A starting
in row 2. HTH Otto
Sub FillBlank()
Dim rColA As Range
Dim i As Range
Dim c As Long
c = 1
Set rColA = Range("A2", Range("A" & Rows.Count).End(xlUp))
For Each i In rColA
If IsEmpty(i.Value) Then
i.Value = c
c = c + 1
End If
Next i
End Sub

"pm" wrote in message
...
I am trying to read the column below, and if a cell is blank, I want to
populate it with a number and increment each subsequent blank after that.
Thanks.


Memo
BAG# 9843 LOCATION# 0000000016
BAG# 1075 LOCATION# 0000000018
BAG# 9841 LOCATION# 0000000016

BAG# 7992 LOCATION# 0000000026
BAG# 9845 LOCATION# 0000000016
BAG# 7990 LOCATION# 0000000026
BAG# 2625 LOCATION# 0000000071
BAG# 1077 LOCATION# 0000000018
BAG# 0136 LOCATION# 0000000061
BAG# 0067 LOCATION# 0000000061

BAG# 0391 LOCATION# 0000000062



  #4   Report Post  
Posted to microsoft.public.excel.misc
pm pm is offline
external usenet poster
 
Posts: 122
Default macro help please!

Thanks....That helped...I got it to work.

"akphidelt" wrote:

You need to create a loop that says something like

Dim x as Integer

x = 1

Do Until '''put what you want here

If ActiveCell.Value = "" Then
ActiveCell.Value = x
x = x + 1
End If

ActiveCell.Offset(1,0).Activate

Loop


"pm" wrote:

I am trying to read the column below, and if a cell is blank, I want to
populate it with a number and increment each subsequent blank after that.
Thanks.


Memo
BAG# 9843 LOCATION# 0000000016
BAG# 1075 LOCATION# 0000000018
BAG# 9841 LOCATION# 0000000016

BAG# 7992 LOCATION# 0000000026
BAG# 9845 LOCATION# 0000000016
BAG# 7990 LOCATION# 0000000026
BAG# 2625 LOCATION# 0000000071
BAG# 1077 LOCATION# 0000000018
BAG# 0136 LOCATION# 0000000061
BAG# 0067 LOCATION# 0000000061

BAG# 0391 LOCATION# 0000000062

  #5   Report Post  
Posted to microsoft.public.excel.misc
pm pm is offline
external usenet poster
 
Posts: 122
Default macro help please!

Thanks. I'll try this one....looks more efficient than mine.

"Otto Moehrbach" wrote:


This little macro will do that. I assumed your data is in Column A starting
in row 2. HTH Otto
Sub FillBlank()
Dim rColA As Range
Dim i As Range
Dim c As Long
c = 1
Set rColA = Range("A2", Range("A" & Rows.Count).End(xlUp))
For Each i In rColA
If IsEmpty(i.Value) Then
i.Value = c
c = c + 1
End If
Next i
End Sub

"pm" wrote in message
...
I am trying to read the column below, and if a cell is blank, I want to
populate it with a number and increment each subsequent blank after that.
Thanks.


Memo
BAG# 9843 LOCATION# 0000000016
BAG# 1075 LOCATION# 0000000018
BAG# 9841 LOCATION# 0000000016

BAG# 7992 LOCATION# 0000000026
BAG# 9845 LOCATION# 0000000016
BAG# 7990 LOCATION# 0000000026
BAG# 2625 LOCATION# 0000000071
BAG# 1077 LOCATION# 0000000018
BAG# 0136 LOCATION# 0000000061
BAG# 0067 LOCATION# 0000000061

BAG# 0391 LOCATION# 0000000062






  #6   Report Post  
Posted to microsoft.public.excel.misc
external usenet poster
 
Posts: 897
Default macro help please!

In addition to what was already posted, this one skips the non-blanks:

Dim rng As Excel.Range
Dim cell As Excel.Range
Dim i As Long

Set rng = Range("A2", Range("A" &
Rows.Count).End(xlUp)).SpecialCells(xlCellTypeBlan ks)

i = 1
For Each cell In rng
cell.Value = i
i = i + 1
Next cell


HTH,
JP

On Mar 19, 3:44*pm, pm wrote:
I am trying to read the column below, and if a cell is blank, I want to
populate it with a number and increment each subsequent blank after that.
Thanks.

Memo
BAG# 9843 * * * *LOCATION# 0000000016
BAG# 1075 * * * *LOCATION# 0000000018
BAG# 9841 * * * *LOCATION# 0000000016

BAG# 7992 * * * *LOCATION# 0000000026
BAG# 9845 * * * *LOCATION# 0000000016
BAG# 7990 * * * *LOCATION# 0000000026
BAG# 2625 * * * *LOCATION# 0000000071
BAG# 1077 * * * *LOCATION# 0000000018
BAG# 0136 * * * *LOCATION# 0000000061
BAG# 0067 * * * *LOCATION# 0000000061

BAG# 0391 * * * *LOCATION# 0000000062


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
Macro Help Needed - Excel 2007 - Print Macro with Auto Sort Gavin Excel Worksheet Functions 0 May 17th 07 01:20 PM
My excel macro recorder no longer shows up when recording macro jack Excel Discussion (Misc queries) 1 February 5th 07 09:31 PM
My excel macro recorder no longer shows up when recording macro jack Excel Discussion (Misc queries) 3 February 5th 07 08:22 PM
using a cell value to control a counter inside a macro and displaying macro value ocset Excel Worksheet Functions 1 September 10th 06 05:32 AM
Macro needed to Paste Values and prevent Macro operation thunderfoot Excel Discussion (Misc queries) 0 June 10th 05 03:38 PM


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

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

About Us

"It's about Microsoft Excel"