How can I set variable in Range
? This is my code:
Sub Makro1()
Dim value As String
ThisWorkbook.Sheets("Arkusz1").Activate
ThisWorkbook.Sheets("Arkusz1").Range("R3").Select
value = ThisWorkbook.Sheets("Arkusz1").Range("R3").value
ThisWorkbook.Worksheets("Arkusz1").Range("C:value").Select '<--- Here is the BUG
Selection.Copy
Selection.PasteSpecial Paste:=xlPasteValues, Operation:=xlNone, SkipBlanks _
:=False, Transpose:=False
Application.CutCopyMode = False
End Sub
CodePudding user response:
Untested
Consider:
Sub Makro1()
Dim valuee As String
ThisWorkbook.Sheets("Arkusz1").Activate
ThisWorkbook.Sheets("Arkusz1").Range("R3").Select
valuee = ThisWorkbook.Sheets("Arkusz1").Range("R3").value
ThisWorkbook.Worksheets("Arkusz1").Range("C" & valuee).Select
Selection.Copy
Selection.PasteSpecial Paste:=xlPasteValues, Operation:=xlNone, SkipBlanks _
:=False, Transpose:=False
Application.CutCopyMode = False
End Sub
CodePudding user response:
For ranges the format is: startColumn & StartRow & ":" & EndColumn & EndRow EndColumn and EndRow are optional is not specified then they will be the same as Startcolumn and StartRow for example to reference a range from column A, row 1 to Column D, Row 20 use:
sAddress = "A1:D20"