Timberwolf
New Member
- Joined
- Feb 20, 2018
- Messages
- 26
Hi all
I have "borrowed" a VBA from the internet and I am trying to alter it to make it do what I need. What I want it to do is look on page "LX" in column A for the word "current" and if it finds it then copy certain cells from that row to the sheet "In Service"
I made some changes and I can get the whole row to copy but can I get just cells B,C,H,I,J,K,L,M only. Here is the current code. Any help would be very much appreciated.
I have "borrowed" a VBA from the internet and I am trying to alter it to make it do what I need. What I want it to do is look on page "LX" in column A for the word "current" and if it finds it then copy certain cells from that row to the sheet "In Service"
I made some changes and I can get the whole row to copy but can I get just cells B,C,H,I,J,K,L,M only. Here is the current code. Any help would be very much appreciated.
Code:
Sub SearchForString()
Dim LSearchRow As Integer
Dim LCopyToRow As Integer
On Error GoTo Err_Execute
LSearchRow = 5
LCopyToRow = 2
While Len(Range("A" & CStr(LSearchRow)).Value) > 0
If Range("A" & CStr(LSearchRow)).Value = "Current" Then
Rows(CStr(LSearchRow) & "B:L" & CStr(LSearchRow)).Select
Selection.Copy
Sheets("In Service").Select
Rows(CStr(LCopyToRow) & ":" & CStr(LCopyToRow)).Select
ActiveSheet.Paste
LCopyToRow = LCopyToRow + 1
Sheets("LX").Select
End If
LSearchRow = LSearchRow + 1
Wend
Application.CutCopyMode = False
Range("A3").Select
MsgBox "All matching data has been copied."
Exit Sub
Err_Execute:
MsgBox "An error occurred."
End Sub
Last edited by a moderator: