• 0

Excel vb Help needed


Question

I need to repeat the following for 70+ rows:

If ROW = 19 Then
    [AC19].Value = [AC19].Value + [F19].Value
    [F19].Value = 0
ElseIf ROW = 20 Then
    [AC20].Value = [AC20].Value + [F20].Value
    [F20].Value = 0
ElseIf ROW = 21 Then
    [AC21].Value = [AC21].Value + [F21].Value
    [F21].Value = 0
End If

Is there a way to use ROW within the variable name itself so that I can use just one entry?

Something like this...

    [AC{ROW}].Value = [AC{ROW}].Value + [F{ROW}].Value
    [F{ROW}].Value = 0

Link to comment
Share on other sites

4 answers to this question

Recommended Posts

  • 0

you can use the indirect function for formula sums. that allows you to pull data from a cell and use it as part of a formula

 

does your program perform this once or multiple times?

Link to comment
Share on other sites

  • 0

There's a series of buttons flowing down the Excel sheet.  The general idea is for someone to enter time against the task, click the button (on that row) and it adds the time to the total, then zero out what they entered.

 

I'm grabbing the row # from one sub, then passing it to this sub. But, I sure don't want to have to code "if on row one, do this".  All of the columns are consistent.

 

I'll look into the Indirect.  Thanks!

Link to comment
Share on other sites

This topic is now closed to further replies.
  • Recently Browsing   0 members

    • No registered users viewing this page.