Hi all,
Really need your help, I apologise for my lack in knowledge but really trying
I am trying to edit some code, to copy cells if the value is greater than 0
So if there is a value in worksheet "inventory" column A to copy cells A1 A2 A3 onto
Worksheet "Sales Invoice" cells A16 and down F16 down and G16 down.
I am really not explaining this well, but I have seen some code on another forum with a similar question which is kind of what i was hoping but it place the values at the bottom and pretty much doesnt do what i was hoping
Sub Button3_Click()
Dim rng As Range
Dim cell As Range
Dim lr As Long
Dim ws1 As Worksheet
Dim ws2 As Worksheet
Set ws1 = Sheets("Inventory")
Set ws2 = Sheets("Sales Invoice")
lr = ws1.Cells(Rows.Count, 1).End(xlUp).Row
Set rng = ws1.Range("H1:H" & lr)
For Each cell In rng
If cell.Value > 0 Then
cell.EntireRow.Copy
If ws2.Range("A1").Value = "" Then
ws2.Range("A1").PasteSpecial xlPasteValues
Else
ws2.Range("A" & Rows.Count).End(xlUp).Offset(1).PasteSpecial xlPasteValues
End If
End If
Next cell
Application.CutCopyMode = False
Range("A1").Select
End Sub
Really need your help, I apologise for my lack in knowledge but really trying
I am trying to edit some code, to copy cells if the value is greater than 0
So if there is a value in worksheet "inventory" column A to copy cells A1 A2 A3 onto
Worksheet "Sales Invoice" cells A16 and down F16 down and G16 down.
I am really not explaining this well, but I have seen some code on another forum with a similar question which is kind of what i was hoping but it place the values at the bottom and pretty much doesnt do what i was hoping
Sub Button3_Click()
Dim rng As Range
Dim cell As Range
Dim lr As Long
Dim ws1 As Worksheet
Dim ws2 As Worksheet
Set ws1 = Sheets("Inventory")
Set ws2 = Sheets("Sales Invoice")
lr = ws1.Cells(Rows.Count, 1).End(xlUp).Row
Set rng = ws1.Range("H1:H" & lr)
For Each cell In rng
If cell.Value > 0 Then
cell.EntireRow.Copy
If ws2.Range("A1").Value = "" Then
ws2.Range("A1").PasteSpecial xlPasteValues
Else
ws2.Range("A" & Rows.Count).End(xlUp).Offset(1).PasteSpecial xlPasteValues
End If
End If
Next cell
Application.CutCopyMode = False
Range("A1").Select
End Sub