Search, copy and past
Closed
limmie
-
4 Aug 2011 à 21:38
venkat1926 Posts 1863 Registration date Sunday 14 June 2009 Status Contributor Last seen 7 August 2021 - 18 Aug 2011 à 22:57
venkat1926 Posts 1863 Registration date Sunday 14 June 2009 Status Contributor Last seen 7 August 2021 - 18 Aug 2011 à 22:57
Related:
- Search, copy and past
- Spybot search and destroy - Download - Antivirus
- Yahoo search history - Guide
- Google search from usa - Guide
- Vim search - Guide
- Search nearby friends on facebook - Guide
3 responses
venkat1926
Posts
1863
Registration date
Sunday 14 June 2009
Status
Contributor
Last seen
7 August 2021
811
5 Aug 2011 à 00:53
5 Aug 2011 à 00:53
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 14 June 2009
Status
Contributor
Last seen
7 August 2021
811
18 Aug 2011 à 22:57
18 Aug 2011 à 22:57
perhaps mind not working efficiently. ;your question no clear. give an example
original data
what it should like
original data
what it should like