Urgent help please in macro, VB
Closed
BJ
-
Dec 13, 2010 at 03:34 AM
venkat1926 Posts 1863 Registration date Sunday June 14, 2009 Status Contributor Last seen August 7, 2021 - Dec 15, 2010 at 04:36 AM
venkat1926 Posts 1863 Registration date Sunday June 14, 2009 Status Contributor Last seen August 7, 2021 - Dec 15, 2010 at 04:36 AM
Related:
- Urgent help please in macro, VB
- Vb net find last row in excel sheet - Guide
- Vb net round - Guide
- Excel online macro - Guide
- Excel run macro on open - Guide
- Macro for number to words in excel - Guide
1 response
venkat1926
Posts
1863
Registration date
Sunday June 14, 2009
Status
Contributor
Last seen
August 7, 2021
811
Dec 15, 2010 at 04:36 AM
Dec 15, 2010 at 04:36 AM
It is not clear where in sheeet1 the account numbers are entered. I assume it is column A. If it is different column you modify the macro the line
With Worksheets("sheet1").Columns("A:A")
the sheet names are sheet1 and sheet 2 and not sheetone and sheettwo.
KEEP YOUR ORIGINAL FILE SAFELY SOMEWHERE SO THAT THE FILE CAN BE RETRIEVED IF THERE IS A MESS UP.
THE MACRO IS
With Worksheets("sheet1").Columns("A:A")
the sheet names are sheet1 and sheet 2 and not sheetone and sheettwo.
KEEP YOUR ORIGINAL FILE SAFELY SOMEWHERE SO THAT THE FILE CAN BE RETRIEVED IF THERE IS A MESS UP.
THE MACRO IS
Sub test()
Dim j, cfind As Range, add As String
With Worksheets("sheet2")
j = .Range("E4").Value
End With
With Worksheets("sheet1").Columns("A:A")
Set cfind = .Cells.Find(what:=j, lookat:=xlWhole)
If Not cfind Is Nothing Then
cfind.EntireRow.Copy
add = cfind.Address
Else
Exit Sub
End If
With Worksheets("sheet2")
.Cells(Rows.Count, "A").End(xlUp).Offset(1, 0).PasteSpecial
End With
Do
Set cfind = .Cells.FindNext(cfind)
If cfind Is Nothing Then Exit Do
If cfind.Address = add Then Exit Do
cfind.EntireRow.Copy
With Worksheets("sheet2")
.Cells(Rows.Count, "A").End(xlUp).Offset(1, 0).PasteSpecial
End With
Loop
End With
Application.CutCopyMode = False
End Sub