PDA

View Full Version : MAcro Help



mdgibbs32
03-03-2017, 04:44 AM
Hi
Im trying to create a macro to copy cells K1 to AE1 to every row that has data in column A. Once it finds an empty cell in column A i want the macro to stop

help please
Mark

SamT
03-03-2017, 05:15 AM
Hunh?

:dunno what you mean.

mdgibbs32
03-03-2017, 05:22 AM
i want to select cells K1 through to AE1 and then copy them down through every row that has data in column A.
For example if A1 through to A? has data i want to copy the cells in ranke k1:Ae1 through to K?:AE?

the problem i have is that the data changes and the amount of rows with data in column A can change (increase)

SamT
03-03-2017, 06:50 AM
Sub CopyAndPaste_KAE()
Dim rngKAE as Range
Dim r as Long

With Sheets("Sheet1") 'Edit to suit
Set rngKAE = .Range("K1:AE1")

For r = 2 to .Cells(Rows.Count, "A").End(xlUp).Row
If .Cells(r, "A") = "" Then .Range("K" & r & ":AE" & r) = rngKAE
Next r
End With
End Sub

.Cells(r, "A") is the same as .Range("A" & r)