ExcelBanter

ExcelBanter (https://www.excelbanter.com/)
-   Excel Programming (https://www.excelbanter.com/excel-programming/)
-   -   filling a row with data, depending on certain criteria (https://www.excelbanter.com/excel-programming/401353-filling-row-data-depending-certain-criteria.html)

MJKelly

filling a row with data, depending on certain criteria
 

Hi,

If I want to loop through a column of data and dependant on the value
of the active cell, fill that row with a value, how would I write the
macro? I can loop through data, but am not sure of how to make sure
the active row is filled and no other, then the next cell in the
column is checked and that row is filled according to the value (which
could be different) and so on?

kind regards,
Matt

Don Guillett

filling a row with data, depending on certain criteria
 

More info?

--
Don Guillett
Microsoft MVP Excel
SalesAid Software

"MJKelly" wrote in message
...

Hi,

If I want to loop through a column of data and dependant on the value
of the active cell, fill that row with a value, how would I write the
macro? I can loop through data, but am not sure of how to make sure
the active row is filled and no other, then the next cell in the
column is checked and that row is filled according to the value (which
could be different) and so on?

kind regards,
Matt



Don Guillett

filling a row with data, depending on certain criteria
 
Pls keep questions in the ng, unless invited otherwise, and please TOP post.

Sub fillcolsif()
For Each c In Range("a2:a10")
If c = "a" Or c = "b" Then
Range(Cells(c.Row, 2), Cells(c.Row, 7)) = "x"
End If
Next
End Sub

I need the macro to look at cell A1 and if the value = "SICK", then
cells B1 to G1 will need to be filled with the value "Absent", if A1 =
"Leave" then again cells B1 to G1 will need to state "Absent". if the
cell value is empty (or the value is anything else), then B1 to G1 can
remain empty. I would then need the macro to proceed to cell A2 and
carry out the same checks, but this time cells B2 to G2 would need to
be completed.

Once all 10 cells A1 to A10 have been checked the macro will end.


--
Don Guillett
Microsoft MVP Excel
SalesAid Software

"Don Guillett" wrote in message
...

More info?

--
Don Guillett
Microsoft MVP Excel
SalesAid Software

"MJKelly" wrote in message
...

Hi,

If I want to loop through a column of data and dependant on the value
of the active cell, fill that row with a value, how would I write the
macro? I can loop through data, but am not sure of how to make sure
the active row is filled and no other, then the next cell in the
column is checked and that row is filled according to the value (which
could be different) and so on?

kind regards,
Matt





All times are GMT +1. The time now is 07:42 PM.

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