Background: I'm a decent Java and C programmer but rather new to VBA programming and having some definite trouble understanding the concepts. The tutorial(s) I've found have been absolutely dreadful. If anyone has suggestions for a good place to start, that's great.
Next, how do the ranges work? Example: I need to write a function that passes in a column number. I then format, calculate, and copy data TO that column from another column in the worksheet. Some crude sample code:
I'm getting myriad "object required" and other such generic errors. I'm sure it's due to a lack of understanding of the basic concepts, but some clarity would be greatly appreciated. How does .Value work? What about Range objects?
TIA,
RJ
************
RudeJohn
************
Next, how do the ranges work? Example: I need to write a function that passes in a column number. I then format, calculate, and copy data TO that column from another column in the worksheet. Some crude sample code:
Code:
Sub myFunction(colNum As Integer)
If colNum = 0 Then Exit Sub
Dim c As Excel.Range
' Unsuccessfully trying to grab cell based on column number. If you pass in "3", I want to capture cell/range "C2" to manipulate it later
Dim temp As String
temp = ColNo2ColRef(colNum) & "2"
c = Range(temp)
' Then I'd like to insert a formula into the cell, based on the range that was selected earlier
temp = Month(c) & "/" & Day(c) & "/" & Year(c)
Cells(2, colNum + 10).Value = Month(currentTop) & "/" & Day(currentTop) & "/" & Year(currentTop)
End Sub
I'm getting myriad "object required" and other such generic errors. I'm sure it's due to a lack of understanding of the basic concepts, but some clarity would be greatly appreciated. How does .Value work? What about Range objects?
TIA,
RJ
************
RudeJohn
************