Search, copy and past
Closed
limmie
-
Aug 4, 2011 at 09:38 PM
venkat1926 Posts 1863 Registration date Sunday June 14, 2009 Status Contributor Last seen August 7, 2021 - Aug 18, 2011 at 10:57 PM
venkat1926 Posts 1863 Registration date Sunday June 14, 2009 Status Contributor Last seen August 7, 2021 - Aug 18, 2011 at 10:57 PM
Related:
- Search, copy and past
- Yahoo search history - Guide
- Safe search settings - Guide
- Google.us search - Guide
- How to search for words on a page - Guide
- Duckduckgo safe search - Guide
3 responses
venkat1926
Posts
1863
Registration date
Sunday June 14, 2009
Status
Contributor
Last seen
August 7, 2021
811
Aug 5, 2011 at 12:53 AM
Aug 5, 2011 at 12:53 AM
the data is like this form A1 onwards
tx_tm am_pm tm_tt gg_tx yt_ab
1 2 2 4 5
1 2 2 4 5
1 2 2 4 5
1 2 2 4 5
1 2 2 4 5
try the macro test below
Sub undo()
Worksheets("sheet1").Cells.Clear
Worksheets("sheet2").Cells.Copy Worksheets("sheet1").Range("A1")
Application.CutCopyMode = False
End Sub
if you want to retest run "undo" first and again run "test"
tx_tm am_pm tm_tt gg_tx yt_ab
1 2 2 4 5
1 2 2 4 5
1 2 2 4 5
1 2 2 4 5
1 2 2 4 5
try the macro test below
Sub test() Dim x As String, findbeg As Range, findend As Range, j As Integer, lastecell As Range Dim m As Integer, n As Integer, lastcell As Range Worksheets("sheet1").Activate x = InputBox("type what string you want in yur case tx") Set lastcell = ActiveSheet.UsedRange.SpecialCells(xlCellTypeLastCell) For j = 1 To lastcell.Column With Columns(j) Set findbeg = .Cells.Find(what:=x, lookat:=xlPart) If findbeg Is Nothing Then GoTo Nextj m = findbeg.Column GoTo nextstep End With Nextj: Next j nextstep: For j = lastcell.Column To 1 Step -1 With Columns(j) Set findend = .Cells.Find(what:=x, lookat:=xlPart) If findend Is Nothing Then GoTo nextj1 n = findend.Column GoTo nextstep1 End With nextj1: Next j nextstep1: Range(Cells(1, findbeg.Column), Cells(1, findend.Column)).EntireColumn.Copy 'Cells(1, Columns.Count).End(xlToLeft).Offset(0, 1).PasteSpecial Cells(1, lastcell.Column + 1).PasteSpecial Application.CutCopyMode = False End Sub
Sub undo()
Worksheets("sheet1").Cells.Clear
Worksheets("sheet2").Cells.Copy Worksheets("sheet1").Range("A1")
Application.CutCopyMode = False
End Sub
if you want to retest run "undo" first and again run "test"
hi venkat1926, thanks a lot for your help...
the coding works but the thing is now, I just want it to look for the (from my example) row 3 only, for the word tx, then copy the entire column and paste it next to the column that contain tx, not at the end of everything.
would you pls help me? thanks a lot....
the coding works but the thing is now, I just want it to look for the (from my example) row 3 only, for the word tx, then copy the entire column and paste it next to the column that contain tx, not at the end of everything.
would you pls help me? thanks a lot....
venkat1926
Posts
1863
Registration date
Sunday June 14, 2009
Status
Contributor
Last seen
August 7, 2021
811
Aug 18, 2011 at 10:57 PM
Aug 18, 2011 at 10:57 PM
perhaps mind not working efficiently. ;your question no clear. give an example
original data
what it should like
original data
what it should like