Hello All
I am hoping someone will be able to help, I have searched the internet for similar problems but have come up with nothing.
I have a form set out in excel and I have started writing a macro adapted from another working macro I found and adapted. I need the macro to find each heading on the form (sheet 2) then copy the data in the cell to the right of those headings. Then paste it into a table on the next sheet (Acquisition) under the appropriate heading without copying over any data that may be already there. The Macro I started below works in part but isn't specific enough, either way I think of changing it, it either copies the whole row or column.
I have attached the worksheets in question (hopefully)
Thank you in advance for any help.
Sub Macromove()
'
Dim myHeaders, e, x, wsR As Worksheet, wsS As Worksheet
Dim r As Range, c As Range
myHeaders = Array(Array("CSID:", "CSID"), Array("O2 CSR:", "O2 CSR"), _
Array("VF CSR:", "VF CSR"))
Set wsS = Sheets("Sheet2")
Set wsR = Sheets("Acquisition")
For Each e In myHeaders
Set r = wsS.Cells.Find(e(0), , , xlWhole)
If Not r Is Nothing Then
Set c = wsR.Cells.Find(e(1), , , xlWhole)
If Not c Is Nothing Then
wsS.Range(r.Offset(, 1), wsS.Cells(Rows.Count, r.Column).End(xlUp)).Copy _
wsR.Cells(Rows.Count, c.Column).End(xlUp)(2)
Else
msg = msg & vbLf & e(1) & " " & wsR.Name
End If
Else
msg = msg & vbLf & e(0) & " " & wsS.Name
End If
Next
If Len(msg) Then
MsgBox "Header not found" & msg
End If
End Sub
Bookmarks