abdelfattah
Well-known Member
- Joined
- May 3, 2019
- Messages
- 1,429
- Office Version
- 2019
- 2010
- Platform
- Windows
hello i have data in sheet1 i would copy data to sheet2 when i choose specific data by inputbox based on column a in sheet 1 then copy to sheet2 and insert row of total with considering when i add a new data relevant data in sheet 2 it add to them and re sum total by the way i got his code and i adjusted but dosn't work
i hope some body help
sheet1
sheet2
i hope some body help
VBA Code:
Sub MoveRowBasedOnCellValue()
'Updated by Extendoffice 2017/11/10
Dim xRg As Range
Dim xCell As Range
Dim I As Long
Dim J As Long
Dim K As Long
I = Worksheets("Sheet1").UsedRange.Rows.Count
J = Worksheets("Sheet2").UsedRange.Rows.Count
If J = 1 Then
If Application.WorksheetFunction.CountA(Worksheets("Sheet2").UsedRange) = 0 Then J = 0
End If
Set xRg = Worksheets("Sheet1").Range("C1:C" & I)
On Error Resume Next
Application.ScreenUpdating = False
For K = 1 To xRg.Count
ss = InputBox(" enter", "search")
If CStr(xRg(K).Value) = "SS" Then
xRg(K).EntireRow.Copy Destination:=Worksheets("Sheet2").Range("A" & J + 1)
J = J + 1
End If
Next
Application.ScreenUpdating = True
End Sub
sheet1
sheet2