filling a row with data, depending on certain criteria

M

MJKelly

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
 
D

Don Guillett

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.
 

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