Want to protect your cyber security and still get fast solutions? Ask a secure question today.Go Premium

x
  • Status: Solved
  • Priority: Medium
  • Security: Public
  • Views: 325
  • Last Modified:

Macro to add "product" (formula value) to cell range

Experts:

I was wondering if someone could assist in helping me define a macro/function that adds calculated values to a cell range in Excel.

Please see attached XLS for details.

Thanks,
EEH
Add-records-to-table--cell-range.xlsx
0
ExpExchHelp
Asked:
ExpExchHelp
  • 3
  • 3
1 Solution
 
KimputerCommented:
This should do it:

Dim i

Private Sub Workbook_Open()
i = 13
End Sub

Sub AddRecord()

Cells(i, 6).Value = Cells(2, 2).Value
i = i + 1


End Sub

Open in new window

0
 
ExpExchHelpAuthor Commented:
Kimputer:

I've added your recommended code to a module.   See attached XLSM.

At this time, it generates an error.

Not sure what's missing.

EEH
Add-records-to-table--cell-range.xlsm
0
 
KimputerCommented:
My code should be in ThisWorkbook, not Module1 (because The Open Workbook routine has to be there, otherwise the first row isn't initialised)
0
Concerto's Cloud Advisory Services

Want to avoid the missteps to gaining all the benefits of the cloud? Learn more about the different assessment options from our Cloud Advisory team.

 
ExpExchHelpAuthor Commented:
Kimputer:

Ok... I moved it into ThisWorkbook... still, I get an error (see attached JPG).
Error.jpg
Add-records-to-table--cell-range.xlsm
0
 
KimputerCommented:
I checked again, the code works. Just re-assign macro to the button.
0
 
ExpExchHelpAuthor Commented:
Got it... works great!   Thanks for the help, Kimputer.
0

Featured Post

Free Tool: Port Scanner

Check which ports are open to the outside world. Helps make sure that your firewall rules are working as intended.

One of a set of tools we are providing to everyone as a way of saying thank you for being a part of the community.

  • 3
  • 3
Tackle projects and never again get stuck behind a technical roadblock.
Join Now