Hi Folks,
I've used this forum for over 3 years to learn everything I can about excel. But I need some help now, as I'm very new to VBA and I need to use it for a macro button. Basically, I want to:
look up a range of cells (F44:F100000(or last blank cell in "F")) to see if it contains a specific cell value (C16)
If it does - I want to copy and paste a selection (F3:P43) to next blank row (I've figured this out by recording a macro)
If it doesn't - don't do anything.
I've googled and googled, but anything I've tried has failed so far. Any help would be much appreciated. Please remember I'm very new to VBA, so it might take me a while to "get it".
This is what I came up with that's failed:
Sub CopyPaste()
If InStr(1, Range("F44:F1000").Value, Range("C16").Value, 1) Then
MsgBox "Invoice number already issued."
Else
Range("F3:P43").Select
Selection.Copy
Range("F3").Select
Selection.End(xlDown).Select
ActiveCell.Offset(1, 0).Select
Selection.PasteSpecial Paste:=xlPasteValues, Operation:=xlNone, SkipBlanks _
:=False, Transpose:=False
Range("C18").Select
End If
End Sub
I've used this forum for over 3 years to learn everything I can about excel. But I need some help now, as I'm very new to VBA and I need to use it for a macro button. Basically, I want to:
look up a range of cells (F44:F100000(or last blank cell in "F")) to see if it contains a specific cell value (C16)
If it does - I want to copy and paste a selection (F3:P43) to next blank row (I've figured this out by recording a macro)
If it doesn't - don't do anything.
I've googled and googled, but anything I've tried has failed so far. Any help would be much appreciated. Please remember I'm very new to VBA, so it might take me a while to "get it".
This is what I came up with that's failed:
Sub CopyPaste()
If InStr(1, Range("F44:F1000").Value, Range("C16").Value, 1) Then
MsgBox "Invoice number already issued."
Else
Range("F3:P43").Select
Selection.Copy
Range("F3").Select
Selection.End(xlDown).Select
ActiveCell.Offset(1, 0).Select
Selection.PasteSpecial Paste:=xlPasteValues, Operation:=xlNone, SkipBlanks _
:=False, Transpose:=False
Range("C18").Select
End If
End Sub