Solved

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

Posted on 2014-04-09
6
319 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 36

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 36

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
PeopleSoft Has Never Been Easier

PeopleSoft Adoption Made Smooth & Simple!

On-The-Job Training Is made Intuitive & Easy With WalkMe's On-Screen Guidance Tool.  Claim Your Free WalkMe Account Now

 

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 36

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

PeopleSoft Has Never Been Easier

PeopleSoft Adoption Made Smooth & Simple!

On-The-Job Training Is made Intuitive & Easy With WalkMe's On-Screen Guidance Tool.  Claim Your Free WalkMe Account Now

Question has a verified solution.

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

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…
You need to know the location of the Office templates folder, so that when you create new templates, they are saved to that location, and thus are available for selection when creating new documents.  The steps to find the Templates folder path are …
This Micro Tutorial will demonstrate how to use longer labels with horizontal bar charts instead of the vertical column chart.
Finds all prime numbers in a range requested and places them in a public primes() array. I've demostrated a template size of 30 (2 * 3 * 5) but larger templates can be built such 210  (2 * 3 * 5 * 7) or 2310  (2 * 3 * 5 * 7 * 11). The larger templa…

688 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