#1   Report Post  
Posted to microsoft.public.excel.worksheet.functions
external usenet poster
 
Posts: 7
Default Macro help

I am trying to create a macro that will add the dollar values in a specific
column. The problem I am having is that the number of vaules in that column
vary depending on the worksheet. Ex. Worksheet 1 has 20 dollar values while
worksheet 2 has 60 dollar values.

How can I create a macro that will, autosense if you will, the number of
values in a specifc column and adjust the formula to meet the needs of
different spreadsheets?
  #2   Report Post  
Posted to microsoft.public.excel.worksheet.functions
external usenet poster
 
Posts: 10,124
Default Macro help

Since you don't fully explain, I'm doing some guessing here. This will go
thru all worksheets after sheet1 and total c2:c last row and put the total
in c1

Sub totalvariablecolumn()
For i = 2 To Worksheets.Count
With Sheets(i)
lr = .Cells(rows.Count, "c").End(xlUp).Row
mysum = Application.Sum(.Range("c2:c" & lr))
'MsgBox mysum
..Cells(1, "c") = mysum
End With
Next i
End Sub

--
Don Guillett
Microsoft MVP Excel
SalesAid Software

"igotquestions" wrote in message
...
I am trying to create a macro that will add the dollar values in a specific
column. The problem I am having is that the number of vaules in that
column
vary depending on the worksheet. Ex. Worksheet 1 has 20 dollar values
while
worksheet 2 has 60 dollar values.

How can I create a macro that will, autosense if you will, the number of
values in a specifc column and adjust the formula to meet the needs of
different spreadsheets?


  #3   Report Post  
Posted to microsoft.public.excel.worksheet.functions
external usenet poster
 
Posts: 7
Default Macro help

Forgive me I am new to this. My situation is:
I use Access to keep job info. One of my forms gives me my parts with dollar
amounts for each job. I analyze this form in Excel. The dollar amounts always
start at cell O4 and proceed down until all of the parts are covered. This
length varies depending on the amount of parts that are in each job. I am
trying to create a macro that I can use to give the the total dollar amount
for all of the parts starting at cell O4 and outputting the total to cell D2.
The variable is the ending cell for the parts dollars. How would I tell the
macro to add everything from O4 down to last dollar amount?

This may be way above my head to comprehend so any help would greatly be
appreciated

"Don Guillett" wrote:

Since you don't fully explain, I'm doing some guessing here. This will go
thru all worksheets after sheet1 and total c2:c last row and put the total
in c1

Sub totalvariablecolumn()
For i = 2 To Worksheets.Count
With Sheets(i)
lr = .Cells(rows.Count, "c").End(xlUp).Row
mysum = Application.Sum(.Range("c2:c" & lr))
'MsgBox mysum
..Cells(1, "c") = mysum
End With
Next i
End Sub

--
Don Guillett
Microsoft MVP Excel
SalesAid Software

"igotquestions" wrote in message
...
I am trying to create a macro that will add the dollar values in a specific
column. The problem I am having is that the number of vaules in that
column
vary depending on the worksheet. Ex. Worksheet 1 has 20 dollar values
while
worksheet 2 has 60 dollar values.

How can I create a macro that will, autosense if you will, the number of
values in a specifc column and adjust the formula to meet the needs of
different spreadsheets?



  #4   Report Post  
Posted to microsoft.public.excel.worksheet.functions
external usenet poster
 
Posts: 11,501
Default Macro help

Hi,

If Don will excuse me for altering his macro try this. Right click your
sheet tab, view code and paste this in and run it

Sub totalvariablecolumn()
With Sheets("Sheet1") 'Change to suit
lr = .Cells(Rows.Count, "O").End(xlUp).Row
mysum = Application.Sum(.Range("O4:O" & lr))
End With
Range("D2").Value = mysum
End Sub

Mike

"igotquestions" wrote:

Forgive me I am new to this. My situation is:
I use Access to keep job info. One of my forms gives me my parts with dollar
amounts for each job. I analyze this form in Excel. The dollar amounts always
start at cell O4 and proceed down until all of the parts are covered. This
length varies depending on the amount of parts that are in each job. I am
trying to create a macro that I can use to give the the total dollar amount
for all of the parts starting at cell O4 and outputting the total to cell D2.
The variable is the ending cell for the parts dollars. How would I tell the
macro to add everything from O4 down to last dollar amount?

This may be way above my head to comprehend so any help would greatly be
appreciated

"Don Guillett" wrote:

Since you don't fully explain, I'm doing some guessing here. This will go
thru all worksheets after sheet1 and total c2:c last row and put the total
in c1

Sub totalvariablecolumn()
For i = 2 To Worksheets.Count
With Sheets(i)
lr = .Cells(rows.Count, "c").End(xlUp).Row
mysum = Application.Sum(.Range("c2:c" & lr))
'MsgBox mysum
..Cells(1, "c") = mysum
End With
Next i
End Sub

--
Don Guillett
Microsoft MVP Excel
SalesAid Software

"igotquestions" wrote in message
...
I am trying to create a macro that will add the dollar values in a specific
column. The problem I am having is that the number of vaules in that
column
vary depending on the worksheet. Ex. Worksheet 1 has 20 dollar values
while
worksheet 2 has 60 dollar values.

How can I create a macro that will, autosense if you will, the number of
values in a specifc column and adjust the formula to meet the needs of
different spreadsheets?



  #5   Report Post  
Posted to microsoft.public.excel.worksheet.functions
external usenet poster
 
Posts: 7
Default Macro help

Thank You so much Mike and Don for your help.
Mike it worked perfectly!

"Mike H" wrote:

Hi,

If Don will excuse me for altering his macro try this. Right click your
sheet tab, view code and paste this in and run it

Sub totalvariablecolumn()
With Sheets("Sheet1") 'Change to suit
lr = .Cells(Rows.Count, "O").End(xlUp).Row
mysum = Application.Sum(.Range("O4:O" & lr))
End With
Range("D2").Value = mysum
End Sub

Mike

"igotquestions" wrote:

Forgive me I am new to this. My situation is:
I use Access to keep job info. One of my forms gives me my parts with dollar
amounts for each job. I analyze this form in Excel. The dollar amounts always
start at cell O4 and proceed down until all of the parts are covered. This
length varies depending on the amount of parts that are in each job. I am
trying to create a macro that I can use to give the the total dollar amount
for all of the parts starting at cell O4 and outputting the total to cell D2.
The variable is the ending cell for the parts dollars. How would I tell the
macro to add everything from O4 down to last dollar amount?

This may be way above my head to comprehend so any help would greatly be
appreciated

"Don Guillett" wrote:

Since you don't fully explain, I'm doing some guessing here. This will go
thru all worksheets after sheet1 and total c2:c last row and put the total
in c1

Sub totalvariablecolumn()
For i = 2 To Worksheets.Count
With Sheets(i)
lr = .Cells(rows.Count, "c").End(xlUp).Row
mysum = Application.Sum(.Range("c2:c" & lr))
'MsgBox mysum
..Cells(1, "c") = mysum
End With
Next i
End Sub

--
Don Guillett
Microsoft MVP Excel
SalesAid Software

"igotquestions" wrote in message
...
I am trying to create a macro that will add the dollar values in a specific
column. The problem I am having is that the number of vaules in that
column
vary depending on the worksheet. Ex. Worksheet 1 has 20 dollar values
while
worksheet 2 has 60 dollar values.

How can I create a macro that will, autosense if you will, the number of
values in a specifc column and adjust the formula to meet the needs of
different spreadsheets?




Reply
Thread Tools Search this Thread
Search this Thread:

Advanced Search
Display Modes

Posting Rules

Smilies are On
[IMG] code is On
HTML code is Off
Trackbacks are On
Pingbacks are On
Refbacks are On


Similar Threads
Thread Thread Starter Forum Replies Last Post
Macro Help Needed - Excel 2007 - Print Macro with Auto Sort Gavin Excel Worksheet Functions 0 May 17th 07 01:20 PM
My excel macro recorder no longer shows up when recording macro jack Excel Discussion (Misc queries) 1 February 5th 07 09:31 PM
My excel macro recorder no longer shows up when recording macro jack Excel Discussion (Misc queries) 3 February 5th 07 08:22 PM
using a cell value to control a counter inside a macro and displaying macro value ocset Excel Worksheet Functions 1 September 10th 06 05:32 AM
Macro needed to Paste Values and prevent Macro operation thunderfoot Excel Discussion (Misc queries) 1 June 11th 05 12:44 AM


All times are GMT +1. The time now is 05:33 PM.

Powered by vBulletin® Copyright ©2000 - 2025, Jelsoft Enterprises Ltd.
Copyright ©2004-2025 ExcelBanter.
The comments are property of their posters.
 

About Us

"It's about Microsoft Excel"