ExcelBanter

ExcelBanter (https://www.excelbanter.com/)
-   Excel Programming (https://www.excelbanter.com/excel-programming/)
-   -   Interesting macro needed (https://www.excelbanter.com/excel-programming/358026-interesting-macro-needed.html)

excelbeginner

Interesting macro needed
 

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

--
excelbeginne
-----------------------------------------------------------------------
excelbeginner's Profile: http://www.excelforum.com/member.php...fo&userid=3222
View this thread: http://www.excelforum.com/showthread.php?threadid=52979


Norman Jones

Interesting macro needed
 
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"
wrote in message
news:excelbeginner.25rchr_1144184142.461@excelforu m-nospam.com...

I need help creating a macro in excel that will fill Cols E - S with the
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,


--
excelbeginner
------------------------------------------------------------------------
excelbeginner's Profile:
http://www.excelforum.com/member.php...o&userid=32228
View this thread: http://www.excelforum.com/showthread...hreadid=529799




excelbeginner

Interesting macro needed
 

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


--
excelbeginner
------------------------------------------------------------------------
excelbeginner's Profile: http://www.excelforum.com/member.php...o&userid=32228
View this thread: http://www.excelforum.com/showthread...hreadid=529799


Norman Jones

Interesting macro needed
 
Hi ExcelBeginner,

Replace MyBook.xls with the name of your workbook.
Replace Sheet1 with the name of your worksheet.


---
Regards,
Norman



"excelbeginner"
wrote in message
news:excelbeginner.25sssy_1144251904.2817@excelfor um-nospam.com...

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


--
excelbeginner
------------------------------------------------------------------------
excelbeginner's Profile:
http://www.excelforum.com/member.php...o&userid=32228
View this thread: http://www.excelforum.com/showthread...hreadid=529799





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

Powered by vBulletin® Copyright ©2000 - 2025, Jelsoft Enterprises Ltd.
ExcelBanter.com