Macro to Run through each tab

J

James8309

Hi All,

I've been trying to figure out how to do this and am keep hitting to a
brick wall.

If anyone can help, that would be appreciated.


I have this excel workbook which has 15 tabs. What I am trying to do
is relatively simple

* Look at column B and if a cell in column B is empty then remove
entire row if a cell in column B is not empty then return the value in
column D in same row.

* Repeat the process from Tab 1 to Tab 15.


Thank you for your help in advance.


Happy New Year.


Regards,


James
 
O

OssieMac

Hi James,

Lets ensure I understand exactly what you want to do.

Test all cells in Column B (within the used range).
If a cell is empty then delete the row.
If the cell is not empty (this is what I don't understand.) Do you want to
copy the value in column D to column B or copy the value from B to column D.
(or something else altogether.)
Repeat the process from Tab 1 to Tab 15. (This is clear.)
 
J

Jacob Skaria

Try the below

Sub Macro()
Dim ws As Worksheet, lngRow As Long
For Each ws In Sheets
For lngRow = ws.Cells(Rows.Count, "B").End(xlUp).Row To 1 Step -1
If ws.Range("B" & lngRow) = "" Then
ws.Rows(lngRow).Delete
Else
ws.Range("D" & lngRow) = ws.Range("B" & lngRow)
End If
Next
Next
End Sub
 

Ask a Question

Want to reply to this thread or ask your own question?

You'll need to choose a username for the site, which only take a couple of moments. After that, you can post your question and our members will help you out.

Ask a Question

Top