Solved

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

Posted on 2014-04-09
6
317 Views
Last Modified: 2014-04-10
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
Comment
Question by:ExpExchHelp
  • 3
  • 3
6 Comments
 
LVL 35

Accepted Solution

by:
Kimputer earned 500 total points
ID: 39989913
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
 

Author Comment

by:ExpExchHelp
ID: 39989975
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
 
LVL 35

Expert Comment

by:Kimputer
ID: 39990116
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
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.

 

Author Comment

by:ExpExchHelp
ID: 39990444
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
 
LVL 35

Expert Comment

by:Kimputer
ID: 39991025
I checked again, the code works. Just re-assign macro to the button.
0
 

Author Comment

by:ExpExchHelp
ID: 39991203
Got it... works great!   Thanks for the help, Kimputer.
0

Featured Post

Free Tool: SSL Checker

Scans your site and returns information about your SSL implementation and certificate. Helpful for debugging and validating your SSL configuration.

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.

Question has a verified solution.

If you are experiencing a similar issue, please ask a related question

A little background as to how I came to I design this code: Around 5 years ago I designed an add-in that formatted Excel files to a corporate standard, applying different cell colours and font type depending on whether the cells contained inputs,…
Excel can be a tricky bit of software to get your head around. Whilst you’ll be able to eventually get to grips with the basic understanding of how to get by, there are a few Excel tips that not everybody will even know about let alone know how to d…
This Micro Tutorial will demonstrate in Google Sheets how to use the HYPERLINK function to create live links inside your spreadsheet.
This Micro Tutorial will demonstrate in Microsoft Excel how to add style and sexy appeal to horizontal bar charts.

839 members asked questions and received personalized solutions in the past 7 days.

Join the community of 500,000 technology professionals and ask your questions.

Join & Ask a Question