copy data from one cell to another
I need to copy data from one column to another, but in the range of cells I am going to, I want 4 spaces in between my numbers. So, my thought was to put all 30 numbers in a column, and then run a function really quick and have it paste the cells for me. I have worked with my for loop in another function, not to copy, but to only read, and using the same Idea there it works fine. This will copy if I type the range numbers in like this:
Range("A1").copy Range("B1")
but this code below does nothing; I want to do it using a for loop as there are 30 peices of data, and I have to do this many many times in many different worksheets, so obviously a function is the cleanest way to do it. The for loop is what I am interested in, the rest of it works fine and I have done this in other functions as well.
Function placeRainData(ByVal dataIn As String, ByVal dataGoing As String)
Dim dataInLetter As Integer
Dim dataGoingLetter As Integer
Dim dataInNumber As Integer
Dim dataGoingNumber As Integer
For l = 1 To UBound(letterArray) 'fill letter array for the loop below A - Z
letterArray(l) = Chr(64 + l)
Next l
dataInLetter = Range(dataIn).Column
dataGoingLetter = Range(dataGoing).Column
dataInNumber = Range(dataIn).Row
dataGoingNumber = Range(dataGoing).Row
For i = 1 To 31
Range(letterArray(dataInLetter) & dataInNumber).Copy Range(letterArray(dataGoingLetter) & dataGoingNumber)
dataInNumber = dataInNumber + 1
dataGoingNumber = dataGoingNumber + 4
Next i
End Function
Not Function:
Functions do not work like that.
Functions are closed procedures which cannot have effect on anthing other than what is put in to the function, used in the function and the output. They are like meat grinders... you put stuff in and other stuff comes out.
You need a Sub to be able to modify the worksheet using Copy etc in the way you want.