• Hi All

    Please note that at the Chandoo.org Forums there is Zero Tolerance to Spam

    Post Spam and you Will Be Deleted as a User

    Hui...

  • When starting a new post, to receive a quicker and more targeted answer, Please include a sample file in the initial post.

Need to understand this

wks.Cells(1, 5) = "Weight"
y = rs.RecordCount

wks.Cells(rs.RecordCount + 2, 4) = "=sum(D2: D" & rs.RecordCount + 1

For x = 2 To rs.RecordCount + 1
wks.Cells(x, 5) = "=D" & x & "/D" & rs.RecordCount + 2
Next x
 
It is setting up a formula to Sum a Range from D2 : Dx
where x is the number of records in file rs
The last For/Next loop is putting a formula in Column E which I think is the Percentage of that row as it is that rows value divided by the last row

For these questions are you aware of being able to step through VBA code as it runs

Go to your code and early in the code move to a line and press F9
Run your code however you do
When the code gets to the line which is now marked it will stop
You can now press F8 and step line by line through your code

Setup VBA and Excel to be besides each other and you can watch what happens on the screen
 
Also, bit of a plug for Chandoo, but if you're going to become much more involved in VBA through your work, you might want to consider going through Chandoo's class on VBA. Having us explain things bit by bit will work a little, but you would benefit more from having a broader understanding.
http://chandoo.org/wp/vba-classes/
 
Back
Top