Interesting macro needed

  • Thread starter Thread starter excelbeginner
  • Start date Start date
E

excelbeginner

I need help creating a macro in excel that will fill Cols E - S with th
number zero for each row that has text in Col A.

something like this:

IF there is text in Cell A1 THEN fill Cells E1-S1 with zeros
IF there is text in Cell A2 THEN fill Cells E2-S2 with zeros
... Until the Cell in Col A that has no text

thank you
 
Hi ExcelBeginner,

Try:

'================>>
Public Sub Tester()
Dim WB As Workbook
Dim SH As Worksheet
Dim rng As Range
Dim rCell As Range

Set WB = Workbooks("MyBook.xls") '<<===== CHANGE
Set SH = WB.Sheets("Sheet1") '<<===== CHANGE

On Error Resume Next
Set rng = Intersect(SH.Columns(1), SH.UsedRange)
On Error GoTo 0

If Not rng Is Nothing Then
For Each rCell In rng.Cells
With rCell
If Not IsEmpty(.Value) Then
.Offset(0, 4).Resize(1, 15).Value = 0
End If
End With
Next rCell
End If
End Sub
'<<================


---
Regards,
Norman



"excelbeginner" <[email protected]>
wrote in message
news:[email protected]...
 
Thank you for your reply, I really appreciate it.

Based on my user name "Excelbeginner" I have a question.
When you indicated
Set WB = Workbooks("MyBook.xls") '<<===== CHANGE
Set SH = WB.Sheets("Sheet1") '<<===== CHANGE

what am I changing and what should I change to?

Thank you very much,
Excelbeginner
 

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

Back
Top