I would like to paste data from a range, copy it in a new range. This new range is supposed to count up its row by +1 (represented by variable i) for each value (self) that is being pasted. I use self, because i need to extract values from a range that includes empty cells.
I tested the first part, the debug print works, so the self values are obtained correctly. I must be making a mistake with the Range(27, i) part, and also with the Set i = 15 part. Help very appreciated. sincerely
Private Sub EvaluateButton_Click()
Dim EvaRange As Range 'Evaluation range
Dim i As Integer 'Counter for free columns
Worksheets("testsheet").Activate
Set EvaRange = Range("C10:C999")
EvaRange.Copy Range("Z15")
Range("Z15:Z999").Select
Set i = 15
For Each self In Selection.SpecialCells(xlCellTypeConstants)
Debug.Print (self)
i = i + 1
self.Copy Range(27, i)
Next
End Sub
Edit: i tried a second version, i think that variables are defined like this: Dim x As Integer x = 6
So shouldn't this work?
Private Sub EvaluateButton_Click()
Dim EvaRange As Range
Dim i As Integer
Worksheets("testsheet").Activate
Set EvaRange = Range("C10:C999")
EvaRange.Copy Range("Z15")
Range("Z15:Z999").Select
i = 15
For Each self In Selection.SpecialCells(xlCellTypeConstants)
Debug.Print (self)
self.Copy Range(27, i)
i = i + 1
Next