PDA

View Full Version : [SOLVED] inputbox vba problem



parscon
04-11-2018, 01:16 AM
Hello i create a VBA that when run it ask for value but when i write a value it does not work. this VBA will check the If Cells(i, 1).Value = "myValue" Then column A and if find the same value will copy from column A to column K to Sheet Report . could you please help to fix input box . it is work fine without input box :(




Sub SpecialCopy()
Dim targetSh As Worksheet
Dim myValue As String
Set targetSh = ThisWorkbook.Worksheets("Report")
Dim i As Long
myValue = InputBox("GPlease Write Company ID")
For i = 1 To Cells(Rows.Count, "A").End(xlUp).Row
If Cells(i, 1).Value = "myValue" Then
Range(Cells(i, 1), Cells(i, 12)).Copy Destination:=targetSh.Range("A" & targetSh.Cells(Rows.Count, "A").End(xlUp).Row + 1)
End If
Next i
End Sub

parscon
04-11-2018, 01:45 AM
Fixed


Sub SpecialCopy()
Dim targetSh As Worksheet
Dim myValue As String
Set targetSh = ThisWorkbook.Worksheets("Report")
Dim i As Long
myValue = InputBox("Please Write Company ID")
For i = 1 To Cells(Rows.Count, "A").End(xlUp).Row
If Cells(i, 1).Value = myValue Then
Range(Cells(i, 1), Cells(i, 12)).Copy Destination:=targetSh.Range("A" & targetSh.Cells(Rows.Count, "A").End(xlUp).Row + 1)
End If
Next i
End Sub