Paste data from AJ to K

L

Louie

I would like to create a macro that performs the following steps but I am
unsuccessful. Can you help me?

1. Check Column AJ for data starting in Row2.
2. If Column AJ has data check the same row of Column K for data
3. If Column K is blank paste the data from the same row of Column AJ into
Column K
 
M

Mike H

Hi,

How about this

Sub Copy_Rows()
Dim LastRow As Long
Dim MyRange as range, C as range
Set sht = Sheets("Sheet1")
LastRow = sht.Cells(Cells.Rows.Count, "AJ").End(xlUp).Row
Set MyRange = Range("AJ2:AJ" & LastRow)
For Each c In MyRange
If Len(c.Value) > 0 And Len(c.Offset(, -25)) = 0 Then
c.Offset(, -25) = c.Value
End If
Next

End Sub

--
Mike

When competing hypotheses are otherwise equal, adopt the hypothesis that
introduces the fewest assumptions while still sufficiently answering the
question.
 
L

Louie

Wow this is really good. Thank you!

Mike H said:
Hi,

How about this

Sub Copy_Rows()
Dim LastRow As Long
Dim MyRange as range, C as range
Set sht = Sheets("Sheet1")
LastRow = sht.Cells(Cells.Rows.Count, "AJ").End(xlUp).Row
Set MyRange = Range("AJ2:AJ" & LastRow)
For Each c In MyRange
If Len(c.Value) > 0 And Len(c.Offset(, -25)) = 0 Then
c.Offset(, -25) = c.Value
End If
Next

End Sub

--
Mike

When competing hypotheses are otherwise equal, adopt the hypothesis that
introduces the fewest assumptions while still sufficiently answering the
question.
 

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