Reply
 
LinkBack Thread Tools Search this Thread Display Modes
  #1   Report Post  
Posted to microsoft.public.excel.programming
external usenet poster
 
Posts: 52
Default Macro HELP!!

I have a spreadsheet that I need to take data from two columns and import
them into a seperate file. I will need to do this often, as the 1st
spreadsheet gets updated daily. And my final product is a monthly total. The
data I need is on a worksheet titled Totals(there's 3 sheets to the
workbook).
Here's my problem. The original data is not always located in the same cell
for example it could look like this one day:
Column B Column K
Row 24 Machine # Total
Row 25 0001 356
Row 26 0002 485
Row 27 0003 569

And the next day

Column B Column K
Row 24 Machine # Total
Row 25 0003 239
Row 26 0001 358
Row 27 0002 302

The machine #'s aren't committed to a certain row number, it's
auto-generated as a report, so I can't do anything about this, but the column
numbers will stay the same

My final product will be a monthly log sheet that will look like this:

Column A Column B
Row 01 Machine # Monthly Total
Row 02 0001 2356
Row 03 0002 3485
Row 04 0003 5569

So my macro needs to search down the row for the appropriate Machine
#(within a range of rows) and when it finds it return the value from Column K
into my Column B.

My VB is a little fuzzy, so excuse the mistakes but I think my format will
need to be somethign like
IF B25(Workbook, Worksheet) = A2 then B2 = K25(Workbook, worksheet) + B2
Else, Nextrow

Am I thinking along the right line?
Also, if you could tell me what my macro should really be, I'd appreciate it.
Also, will I need to do this update of my monthly report everyday? And will
the filename I'm drawing from need to be the same each time, or can I select
the file to draw from? (is that confusing?)

THANK-YOU
Any help is greatly appreciated, I'm having trouble finding all my answers
by looking thru help files.
  #2   Report Post  
Posted to microsoft.public.excel.programming
ben ben is offline
external usenet poster
 
Posts: 232
Default Macro HELP!!

Jenny,

Are you wanting to use worksheet functions to do this or VBA with a macro?
The formula you gave was in worksheet function format, vba would look more
like

sub totalmachines()
dim ran as range
dim wks as worksheet
dim iwks as worksheet
dim dailyTot as range
dim monthtot as range
set wks = activesheet
set iwks = workbooks("workbook to send to").sheets(1)
set ran = wks.columns("b").find(what:="machine#000", _
lookat:=xlwhole)
if ran is nothing then
msgbox "Machine # not found"
exit sub
end if
set dailytot = ran.offset(0,12)
'here we add it to the monthly total
set ran = iwks.columns("b").find(what:="machine#000", _
lookat:=xlwhole)
if ran is nothing then
msgbox "Machine # not found"
exit sub
end if
set monthtot = ran.offset(0,12)
monthtot = monthtot + dailytot
end sub




--
When you lose your mind, you free your life.


"Jenny" wrote:

I have a spreadsheet that I need to take data from two columns and import
them into a seperate file. I will need to do this often, as the 1st
spreadsheet gets updated daily. And my final product is a monthly total. The
data I need is on a worksheet titled Totals(there's 3 sheets to the
workbook).
Here's my problem. The original data is not always located in the same cell
for example it could look like this one day:
Column B Column K
Row 24 Machine # Total
Row 25 0001 356
Row 26 0002 485
Row 27 0003 569

And the next day

Column B Column K
Row 24 Machine # Total
Row 25 0003 239
Row 26 0001 358
Row 27 0002 302

The machine #'s aren't committed to a certain row number, it's
auto-generated as a report, so I can't do anything about this, but the column
numbers will stay the same

My final product will be a monthly log sheet that will look like this:

Column A Column B
Row 01 Machine # Monthly Total
Row 02 0001 2356
Row 03 0002 3485
Row 04 0003 5569

So my macro needs to search down the row for the appropriate Machine
#(within a range of rows) and when it finds it return the value from Column K
into my Column B.

My VB is a little fuzzy, so excuse the mistakes but I think my format will
need to be somethign like
IF B25(Workbook, Worksheet) = A2 then B2 = K25(Workbook, worksheet) + B2
Else, Nextrow

Am I thinking along the right line?
Also, if you could tell me what my macro should really be, I'd appreciate it.
Also, will I need to do this update of my monthly report everyday? And will
the filename I'm drawing from need to be the same each time, or can I select
the file to draw from? (is that confusing?)

THANK-YOU
Any help is greatly appreciated, I'm having trouble finding all my answers
by looking thru help files.

  #3   Report Post  
Posted to microsoft.public.excel.programming
external usenet poster
 
Posts: 52
Default Macro HELP!!

Thanks for your reply. I would like to use whichever is simpler, I'm doing
this for my father, so I want to make it as simple as possible. Thanks for
your help!!

"ben" wrote:

Jenny,

Are you wanting to use worksheet functions to do this or VBA with a macro?
The formula you gave was in worksheet function format, vba would look more
like

sub totalmachines()
dim ran as range
dim wks as worksheet
dim iwks as worksheet
dim dailyTot as range
dim monthtot as range
set wks = activesheet
set iwks = workbooks("workbook to send to").sheets(1)
set ran = wks.columns("b").find(what:="machine#000", _
lookat:=xlwhole)
if ran is nothing then
msgbox "Machine # not found"
exit sub
end if
set dailytot = ran.offset(0,12)
'here we add it to the monthly total
set ran = iwks.columns("b").find(what:="machine#000", _
lookat:=xlwhole)
if ran is nothing then
msgbox "Machine # not found"
exit sub
end if
set monthtot = ran.offset(0,12)
monthtot = monthtot + dailytot
end sub




--
When you lose your mind, you free your life.


"Jenny" wrote:

I have a spreadsheet that I need to take data from two columns and import
them into a seperate file. I will need to do this often, as the 1st
spreadsheet gets updated daily. And my final product is a monthly total. The
data I need is on a worksheet titled Totals(there's 3 sheets to the
workbook).
Here's my problem. The original data is not always located in the same cell
for example it could look like this one day:
Column B Column K
Row 24 Machine # Total
Row 25 0001 356
Row 26 0002 485
Row 27 0003 569

And the next day

Column B Column K
Row 24 Machine # Total
Row 25 0003 239
Row 26 0001 358
Row 27 0002 302

The machine #'s aren't committed to a certain row number, it's
auto-generated as a report, so I can't do anything about this, but the column
numbers will stay the same

My final product will be a monthly log sheet that will look like this:

Column A Column B
Row 01 Machine # Monthly Total
Row 02 0001 2356
Row 03 0002 3485
Row 04 0003 5569

So my macro needs to search down the row for the appropriate Machine
#(within a range of rows) and when it finds it return the value from Column K
into my Column B.

My VB is a little fuzzy, so excuse the mistakes but I think my format will
need to be somethign like
IF B25(Workbook, Worksheet) = A2 then B2 = K25(Workbook, worksheet) + B2
Else, Nextrow

Am I thinking along the right line?
Also, if you could tell me what my macro should really be, I'd appreciate it.
Also, will I need to do this update of my monthly report everyday? And will
the filename I'm drawing from need to be the same each time, or can I select
the file to draw from? (is that confusing?)

THANK-YOU
Any help is greatly appreciated, I'm having trouble finding all my answers
by looking thru help files.

  #4   Report Post  
Posted to microsoft.public.excel.programming
ben ben is offline
external usenet poster
 
Posts: 232
Default Macro HELP!!

well that's a manner of choice, with the worksheetfunction both must be
opened and saved manually, with the vba you have the choice of a lot more
automatics

--
When you lose your mind, you free your life.


"Jenny" wrote:

Thanks for your reply. I would like to use whichever is simpler, I'm doing
this for my father, so I want to make it as simple as possible. Thanks for
your help!!

"ben" wrote:

Jenny,

Are you wanting to use worksheet functions to do this or VBA with a macro?
The formula you gave was in worksheet function format, vba would look more
like

sub totalmachines()
dim ran as range
dim wks as worksheet
dim iwks as worksheet
dim dailyTot as range
dim monthtot as range
set wks = activesheet
set iwks = workbooks("workbook to send to").sheets(1)
set ran = wks.columns("b").find(what:="machine#000", _
lookat:=xlwhole)
if ran is nothing then
msgbox "Machine # not found"
exit sub
end if
set dailytot = ran.offset(0,12)
'here we add it to the monthly total
set ran = iwks.columns("b").find(what:="machine#000", _
lookat:=xlwhole)
if ran is nothing then
msgbox "Machine # not found"
exit sub
end if
set monthtot = ran.offset(0,12)
monthtot = monthtot + dailytot
end sub




--
When you lose your mind, you free your life.


"Jenny" wrote:

I have a spreadsheet that I need to take data from two columns and import
them into a seperate file. I will need to do this often, as the 1st
spreadsheet gets updated daily. And my final product is a monthly total. The
data I need is on a worksheet titled Totals(there's 3 sheets to the
workbook).
Here's my problem. The original data is not always located in the same cell
for example it could look like this one day:
Column B Column K
Row 24 Machine # Total
Row 25 0001 356
Row 26 0002 485
Row 27 0003 569

And the next day

Column B Column K
Row 24 Machine # Total
Row 25 0003 239
Row 26 0001 358
Row 27 0002 302

The machine #'s aren't committed to a certain row number, it's
auto-generated as a report, so I can't do anything about this, but the column
numbers will stay the same

My final product will be a monthly log sheet that will look like this:

Column A Column B
Row 01 Machine # Monthly Total
Row 02 0001 2356
Row 03 0002 3485
Row 04 0003 5569

So my macro needs to search down the row for the appropriate Machine
#(within a range of rows) and when it finds it return the value from Column K
into my Column B.

My VB is a little fuzzy, so excuse the mistakes but I think my format will
need to be somethign like
IF B25(Workbook, Worksheet) = A2 then B2 = K25(Workbook, worksheet) + B2
Else, Nextrow

Am I thinking along the right line?
Also, if you could tell me what my macro should really be, I'd appreciate it.
Also, will I need to do this update of my monthly report everyday? And will
the filename I'm drawing from need to be the same each time, or can I select
the file to draw from? (is that confusing?)

THANK-YOU
Any help is greatly appreciated, I'm having trouble finding all my answers
by looking thru help files.

  #5   Report Post  
Posted to microsoft.public.excel.programming
external usenet poster
 
Posts: 52
Default Macro HELP!!

Well which would work better if the source of the data's named changed daily.
Beacuse this report is generated automatically, so I'm assuming the name
might change according to the date.

"ben" wrote:

well that's a manner of choice, with the worksheetfunction both must be
opened and saved manually, with the vba you have the choice of a lot more
automatics

--
When you lose your mind, you free your life.


"Jenny" wrote:

Thanks for your reply. I would like to use whichever is simpler, I'm doing
this for my father, so I want to make it as simple as possible. Thanks for
your help!!

"ben" wrote:

Jenny,

Are you wanting to use worksheet functions to do this or VBA with a macro?
The formula you gave was in worksheet function format, vba would look more
like

sub totalmachines()
dim ran as range
dim wks as worksheet
dim iwks as worksheet
dim dailyTot as range
dim monthtot as range
set wks = activesheet
set iwks = workbooks("workbook to send to").sheets(1)
set ran = wks.columns("b").find(what:="machine#000", _
lookat:=xlwhole)
if ran is nothing then
msgbox "Machine # not found"
exit sub
end if
set dailytot = ran.offset(0,12)
'here we add it to the monthly total
set ran = iwks.columns("b").find(what:="machine#000", _
lookat:=xlwhole)
if ran is nothing then
msgbox "Machine # not found"
exit sub
end if
set monthtot = ran.offset(0,12)
monthtot = monthtot + dailytot
end sub




--
When you lose your mind, you free your life.


"Jenny" wrote:

I have a spreadsheet that I need to take data from two columns and import
them into a seperate file. I will need to do this often, as the 1st
spreadsheet gets updated daily. And my final product is a monthly total. The
data I need is on a worksheet titled Totals(there's 3 sheets to the
workbook).
Here's my problem. The original data is not always located in the same cell
for example it could look like this one day:
Column B Column K
Row 24 Machine # Total
Row 25 0001 356
Row 26 0002 485
Row 27 0003 569

And the next day

Column B Column K
Row 24 Machine # Total
Row 25 0003 239
Row 26 0001 358
Row 27 0002 302

The machine #'s aren't committed to a certain row number, it's
auto-generated as a report, so I can't do anything about this, but the column
numbers will stay the same

My final product will be a monthly log sheet that will look like this:

Column A Column B
Row 01 Machine # Monthly Total
Row 02 0001 2356
Row 03 0002 3485
Row 04 0003 5569

So my macro needs to search down the row for the appropriate Machine
#(within a range of rows) and when it finds it return the value from Column K
into my Column B.

My VB is a little fuzzy, so excuse the mistakes but I think my format will
need to be somethign like
IF B25(Workbook, Worksheet) = A2 then B2 = K25(Workbook, worksheet) + B2
Else, Nextrow

Am I thinking along the right line?
Also, if you could tell me what my macro should really be, I'd appreciate it.
Also, will I need to do this update of my monthly report everyday? And will
the filename I'm drawing from need to be the same each time, or can I select
the file to draw from? (is that confusing?)

THANK-YOU
Any help is greatly appreciated, I'm having trouble finding all my answers
by looking thru help files.



  #6   Report Post  
Posted to microsoft.public.excel.programming
ben ben is offline
external usenet poster
 
Posts: 232
Default Macro HELP!!

You could theoretically use worksheetfunction to do this, and would be easier
for the changing workbook names, but you have cell values changing themselves
which would run into problems this way, if you used a macro you could get
over this problem, but now you run into getting both the workbooks open at
the same time, I would reccomend, using a macro that is embedded in the
monthly .xls file, and then it asks which workbook to grab the data from.
Ben

--
When you lose your mind, you free your life.


"Jenny" wrote:

Well which would work better if the source of the data's named changed daily.
Beacuse this report is generated automatically, so I'm assuming the name
might change according to the date.

"ben" wrote:

well that's a manner of choice, with the worksheetfunction both must be
opened and saved manually, with the vba you have the choice of a lot more
automatics

--
When you lose your mind, you free your life.


"Jenny" wrote:

Thanks for your reply. I would like to use whichever is simpler, I'm doing
this for my father, so I want to make it as simple as possible. Thanks for
your help!!

"ben" wrote:

Jenny,

Are you wanting to use worksheet functions to do this or VBA with a macro?
The formula you gave was in worksheet function format, vba would look more
like

sub totalmachines()
dim ran as range
dim wks as worksheet
dim iwks as worksheet
dim dailyTot as range
dim monthtot as range
set wks = activesheet
set iwks = workbooks("workbook to send to").sheets(1)
set ran = wks.columns("b").find(what:="machine#000", _
lookat:=xlwhole)
if ran is nothing then
msgbox "Machine # not found"
exit sub
end if
set dailytot = ran.offset(0,12)
'here we add it to the monthly total
set ran = iwks.columns("b").find(what:="machine#000", _
lookat:=xlwhole)
if ran is nothing then
msgbox "Machine # not found"
exit sub
end if
set monthtot = ran.offset(0,12)
monthtot = monthtot + dailytot
end sub




--
When you lose your mind, you free your life.


"Jenny" wrote:

I have a spreadsheet that I need to take data from two columns and import
them into a seperate file. I will need to do this often, as the 1st
spreadsheet gets updated daily. And my final product is a monthly total. The
data I need is on a worksheet titled Totals(there's 3 sheets to the
workbook).
Here's my problem. The original data is not always located in the same cell
for example it could look like this one day:
Column B Column K
Row 24 Machine # Total
Row 25 0001 356
Row 26 0002 485
Row 27 0003 569

And the next day

Column B Column K
Row 24 Machine # Total
Row 25 0003 239
Row 26 0001 358
Row 27 0002 302

The machine #'s aren't committed to a certain row number, it's
auto-generated as a report, so I can't do anything about this, but the column
numbers will stay the same

My final product will be a monthly log sheet that will look like this:

Column A Column B
Row 01 Machine # Monthly Total
Row 02 0001 2356
Row 03 0002 3485
Row 04 0003 5569

So my macro needs to search down the row for the appropriate Machine
#(within a range of rows) and when it finds it return the value from Column K
into my Column B.

My VB is a little fuzzy, so excuse the mistakes but I think my format will
need to be somethign like
IF B25(Workbook, Worksheet) = A2 then B2 = K25(Workbook, worksheet) + B2
Else, Nextrow

Am I thinking along the right line?
Also, if you could tell me what my macro should really be, I'd appreciate it.
Also, will I need to do this update of my monthly report everyday? And will
the filename I'm drawing from need to be the same each time, or can I select
the file to draw from? (is that confusing?)

THANK-YOU
Any help is greatly appreciated, I'm having trouble finding all my answers
by looking thru help files.

  #7   Report Post  
Posted to microsoft.public.excel.programming
external usenet poster
 
Posts: 52
Default Macro HELP!!

That would be perfect. How do I set that up?

"ben" wrote:

You could theoretically use worksheetfunction to do this, and would be easier
for the changing workbook names, but you have cell values changing themselves
which would run into problems this way, if you used a macro you could get
over this problem, but now you run into getting both the workbooks open at
the same time, I would reccomend, using a macro that is embedded in the
monthly .xls file, and then it asks which workbook to grab the data from.
Ben

--
When you lose your mind, you free your life.


"Jenny" wrote:

Well which would work better if the source of the data's named changed daily.
Beacuse this report is generated automatically, so I'm assuming the name
might change according to the date.

"ben" wrote:

well that's a manner of choice, with the worksheetfunction both must be
opened and saved manually, with the vba you have the choice of a lot more
automatics

--
When you lose your mind, you free your life.


"Jenny" wrote:

Thanks for your reply. I would like to use whichever is simpler, I'm doing
this for my father, so I want to make it as simple as possible. Thanks for
your help!!

"ben" wrote:

Jenny,

Are you wanting to use worksheet functions to do this or VBA with a macro?
The formula you gave was in worksheet function format, vba would look more
like

sub totalmachines()
dim ran as range
dim wks as worksheet
dim iwks as worksheet
dim dailyTot as range
dim monthtot as range
set wks = activesheet
set iwks = workbooks("workbook to send to").sheets(1)
set ran = wks.columns("b").find(what:="machine#000", _
lookat:=xlwhole)
if ran is nothing then
msgbox "Machine # not found"
exit sub
end if
set dailytot = ran.offset(0,12)
'here we add it to the monthly total
set ran = iwks.columns("b").find(what:="machine#000", _
lookat:=xlwhole)
if ran is nothing then
msgbox "Machine # not found"
exit sub
end if
set monthtot = ran.offset(0,12)
monthtot = monthtot + dailytot
end sub




--
When you lose your mind, you free your life.


"Jenny" wrote:

I have a spreadsheet that I need to take data from two columns and import
them into a seperate file. I will need to do this often, as the 1st
spreadsheet gets updated daily. And my final product is a monthly total. The
data I need is on a worksheet titled Totals(there's 3 sheets to the
workbook).
Here's my problem. The original data is not always located in the same cell
for example it could look like this one day:
Column B Column K
Row 24 Machine # Total
Row 25 0001 356
Row 26 0002 485
Row 27 0003 569

And the next day

Column B Column K
Row 24 Machine # Total
Row 25 0003 239
Row 26 0001 358
Row 27 0002 302

The machine #'s aren't committed to a certain row number, it's
auto-generated as a report, so I can't do anything about this, but the column
numbers will stay the same

My final product will be a monthly log sheet that will look like this:

Column A Column B
Row 01 Machine # Monthly Total
Row 02 0001 2356
Row 03 0002 3485
Row 04 0003 5569

So my macro needs to search down the row for the appropriate Machine
#(within a range of rows) and when it finds it return the value from Column K
into my Column B.

My VB is a little fuzzy, so excuse the mistakes but I think my format will
need to be somethign like
IF B25(Workbook, Worksheet) = A2 then B2 = K25(Workbook, worksheet) + B2
Else, Nextrow

Am I thinking along the right line?
Also, if you could tell me what my macro should really be, I'd appreciate it.
Also, will I need to do this update of my monthly report everyday? And will
the filename I'm drawing from need to be the same each time, or can I select
the file to draw from? (is that confusing?)

THANK-YOU
Any help is greatly appreciated, I'm having trouble finding all my answers
by looking thru help files.

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 recorded... tabs & file names changed, macro hangs Steve Excel Worksheet Functions 3 October 30th 09 11:41 AM
Macro Help Needed - Excel 2007 - Print Macro with Auto Sort Gavin Excel Worksheet Functions 0 May 17th 07 01:20 PM
how to count/sum by function/macro to get the number of record to do copy/paste in macro tango Excel Programming 1 October 15th 04 01:16 PM
macro to delete entire rows when column A is blank ...a quick macro vikram Excel Programming 4 May 3rd 04 08:45 PM
Start Macro / Stop Macro / Restart Macro Pete[_13_] Excel Programming 2 November 21st 03 05:04 PM


All times are GMT +1. The time now is 02:03 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"