george hart
Board Regular
- Joined
- Dec 4, 2008
- Messages
- 241
Hi
I have data I need to select then copy to another worksheet. The code below works fine if the data I want is in more than one row. But, when I have data in only one row it falls over because it copies the data I want and all the enty cells/rows below - this causes a problem when pasting, because paste area are not the same size/shape etc...I've tried changing the code in allsorts of ways but cant figure it out...I'm going mad!
Sheets("LAIRA STOP").Select
Cells.Find(What:="power cars", After:=ActiveCell, LookIn:=xlFormulas, _
LookAt:=xlPart, SearchOrder:=xlByRows, SearchDirection:=xlNext, _
MatchCase:=False).Activate
ActiveCell.Offset(1, 0).Select
Range(Selection, Selection.End(xlToLeft)).Select
Range(Selection, Selection.End(xlToRight)).Select
Range(Selection, Selection.End(xlDown)).Select
Selection.Copy
Sheets("Data").Select
Range("A" & Rows.Count).End(xlUp).Offset(1).Select
Selection.PasteSpecial Paste:=xlValues, Operation:=xlNone, SkipBlanks:= _
False, Transpose:=False
Application.CutCopyMode = False
Selection.Columns("B").Value = "LA"
I have data I need to select then copy to another worksheet. The code below works fine if the data I want is in more than one row. But, when I have data in only one row it falls over because it copies the data I want and all the enty cells/rows below - this causes a problem when pasting, because paste area are not the same size/shape etc...I've tried changing the code in allsorts of ways but cant figure it out...I'm going mad!
Sheets("LAIRA STOP").Select
Cells.Find(What:="power cars", After:=ActiveCell, LookIn:=xlFormulas, _
LookAt:=xlPart, SearchOrder:=xlByRows, SearchDirection:=xlNext, _
MatchCase:=False).Activate
ActiveCell.Offset(1, 0).Select
Range(Selection, Selection.End(xlToLeft)).Select
Range(Selection, Selection.End(xlToRight)).Select
Range(Selection, Selection.End(xlDown)).Select
Selection.Copy
Sheets("Data").Select
Range("A" & Rows.Count).End(xlUp).Offset(1).Select
Selection.PasteSpecial Paste:=xlValues, Operation:=xlNone, SkipBlanks:= _
False, Transpose:=False
Application.CutCopyMode = False
Selection.Columns("B").Value = "LA"