I am copying cells from one worksheet to another. If I hard code in a cell address it works fine. But I want to copy only certain cells from a row that the user selects. How do I assign the row ID to a variable.
Here is the code that I have so far:
Private Sub cmdPaySlip_Click()
Dim myRow As String 'is this the right datatype?
If Selection.Rows.Count = 1 And Selection.Columns.Count > 2 Then
'myRow = ????????? how do I do this?
Range(myRow, 4).Select 'is this right?
Selection.Copy
Sheets("Pay Slip".Select
ActiveSheet.Range("B6".Select
ActiveSheet.Paste
Else
MsgBox ("Please select a week to process."
End If
End Sub
Here is the code that I have so far:
Private Sub cmdPaySlip_Click()
Dim myRow As String 'is this the right datatype?
If Selection.Rows.Count = 1 And Selection.Columns.Count > 2 Then
'myRow = ????????? how do I do this?
Range(myRow, 4).Select 'is this right?
Selection.Copy
Sheets("Pay Slip".Select
ActiveSheet.Range("B6".Select
ActiveSheet.Paste
Else
MsgBox ("Please select a week to process."
End If
End Sub