#1   Report Post  
Posted to microsoft.public.excel.misc
external usenet poster
 
Posts: 122
Default Set up an If Macro



Trying to write a macro to fill in the blank spots in column B. So if B2 =
"" Then "Not ATT" if cell is not blank then skip cell, retain data and move
to the next and keep processing until all data reviewed.

A B
1 John Smith ATT
2 Tom Jones
3 Jane Henry DNS

  #2   Report Post  
Posted to microsoft.public.excel.misc
external usenet poster
 
Posts: 10,124
Default Set up an If Macro

How about selecting the rangeeditreplaceleave blankwith Not ATT

--
Don Guillett
Microsoft MVP Excel
SalesAid Software

"Melissa" wrote in message
...


Trying to write a macro to fill in the blank spots in column B. So if B2 =
"" Then "Not ATT" if cell is not blank then skip cell, retain data and
move
to the next and keep processing until all data reviewed.

A B
1 John Smith ATT
2 Tom Jones
3 Jane Henry DNS


  #3   Report Post  
Posted to microsoft.public.excel.misc
external usenet poster
 
Posts: 18
Default Set up an If Macro



"Roger Govier" wrote:

Hi

Sub Fillblanks()
Dim lr As Long
Rows("1:1").Insert Shift:=xlDown
lr = Cells(Rows.Count, "A").End(xlUp).Row
Range("A1:B1").AutoFilter
Selection.AutoFilter Field:=2, Criteria1:="="
Range("B2:B" & lr) = "Not ATT"
Rows("1:1").Delete
End Sub

Copy code above
Alt+F11 to invoke VB Editor
InsertModule
Paste code into white pane that appears
Alt+F11 to rturn to Excel

To use
Alt+F8
Select macro FillblanksRun

--
Regards
Roger Govier

"Melissa" wrote in message
...


Trying to write a macro to fill in the blank spots in column B. So if B2 =
"" Then "Not ATT" if cell is not blank then skip cell, retain data and
move
to the next and keep processing until all data reviewed.

A B
1 John Smith ATT
2 Tom Jones
3 Jane Henry DNS


Roger -

How would I need to change the macro if I wanted to get the cell populated
with the data from the last field that it found was populated... for example:

I have the following data:

A | B

10 |
| Adam
| Mike
| John

12 |
| Stan
| Frank

and I want:

10 |
10 | Adam
10 | Mike
10 | John
12 |
12 | Stan
12 | Frank

I could obviously just drag down, but there are just too many.

THanks,
  #4   Report Post  
Posted to microsoft.public.excel.misc
external usenet poster
 
Posts: 2,480
Default Set up an If Macro

Hi

the following should do what you want

Sub Fillblanks2()
Application.ScreenUpdating = False
Dim lr As Long, i As Long

lr = Cells(Rows.Count, "B").End(xlUp).Row
For i = 2 To lr
If Cells(i, 1) = "" And Cells(i, 2) = "" Then Rows(i).Delete
If Cells(i, 2) < "" Then
Cells(i, 1) = Cells(i - 1, 1).Value
End If
Next i
Application.ScreenUpdating = True
End Sub

I have followed your example literally, and if there is a blank row between
the sets of data, then it gets deleted.
If you don't want that, then just remove the line
If Cells(i, 1) = "" And Cells(i, 2) = "" Then Rows(i).Delete

--
Regards
Roger Govier

"Wilson" wrote in message
...


"Roger Govier" wrote:

Hi

Sub Fillblanks()
Dim lr As Long
Rows("1:1").Insert Shift:=xlDown
lr = Cells(Rows.Count, "A").End(xlUp).Row
Range("A1:B1").AutoFilter
Selection.AutoFilter Field:=2, Criteria1:="="
Range("B2:B" & lr) = "Not ATT"
Rows("1:1").Delete
End Sub

Copy code above
Alt+F11 to invoke VB Editor
InsertModule
Paste code into white pane that appears
Alt+F11 to rturn to Excel

To use
Alt+F8
Select macro FillblanksRun

--
Regards
Roger Govier

"Melissa" wrote in message
...


Trying to write a macro to fill in the blank spots in column B. So if
B2 =
"" Then "Not ATT" if cell is not blank then skip cell, retain data and
move
to the next and keep processing until all data reviewed.

A B
1 John Smith ATT
2 Tom Jones
3 Jane Henry DNS


Roger -

How would I need to change the macro if I wanted to get the cell populated
with the data from the last field that it found was populated... for
example:

I have the following data:

A | B

10 |
| Adam
| Mike
| John

12 |
| Stan
| Frank

and I want:

10 |
10 | Adam
10 | Mike
10 | John
12 |
12 | Stan
12 | Frank

I could obviously just drag down, but there are just too many.

THanks,


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
need help to update macro to office 2007 macro enabled workbook jatman Excel Discussion (Misc queries) 1 December 14th 07 01:57 PM
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


All times are GMT +1. The time now is 09:30 AM.

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"