Solved

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

Posted on 2014-04-09
6
318 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
[X]
Welcome to Experts Exchange

Add your voice to the tech community where 5M+ people just like you are talking about what matters.

  • Help others & share knowledge
  • Earn cash & points
  • Learn & ask questions
  • 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
Industry Leaders: We Want Your Opinion!

We value your feedback.

Take our survey and automatically be enter to win anyone of the following:
Yeti Cooler, Amazon eGift Card, and Movie eGift Card!

 

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

Online Training Solution

Drastically shorten your training time with WalkMe's advanced online training solution that Guides your trainees to action. Forget about retraining and skyrocket knowledge retention rates.

Question has a verified solution.

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

This article descibes how to create a connection between Excel and SAP and how to move data from Excel to SAP or the other way around.
Access developers frequently have requirements to interact with Excel (import from or output to) in their applications.  You might be able to accomplish this with the TransferSpreadsheet and OutputTo methods, but in this series of articles I will di…
This Micro Tutorial demonstrates how to create Excel charts: column, area, line, bar, and scatter charts. Formatting tips are provided as well.
This Micro Tutorial will demonstrate how to use a scrolling table in Microsoft Excel using the INDEX function.

730 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