Reply
 
LinkBack Thread Tools Search this Thread Display Modes
  #1   Report Post  
Posted to microsoft.public.excel.programming
external usenet poster
 
Posts: 5
Default Macro referencing identical text

Hi

I am new to Macros and think they are great. I work in food
manufacturing and do a lot of work in costing materials usage etc

Everyday I run a file from my ERP system from work and generate it as
an excel file.

I then do loads of calculations based on aggregating the financial
costs of items so for instance I may want to look at 'ingredients' by
aggregating jam, sugar, glucose etc. The trouble is that these items
are not necessarily on the same row each time I run the report from my
ERP. Is there anyway I can create a macro that will locate and
calculate the materials by their names rather than a cell reference?

Regards

Brian

  #2   Report Post  
Posted to microsoft.public.excel.programming
external usenet poster
 
Posts: 923
Default Macro referencing identical text

A simple way, assuming that your data is stored in single rows, would be to
scan all rows and using some reference cell that contains the name of the
product, you then run a set of code.

Something like.....

Sub Test()
Dim xRow As Long, xLastRow As Long
With Sheets("Sheet1")
xLastRow = .Cells(Rows.Count, 1).End(xlUp).Row

For xRow = 1 To xLastRow
' put some generic code here that applies to every row

Select Case .Cells(xRow, 1)

Case Is = "Jam"
' some code here to process jam

Case Is = "Sugar"
' some code her to process sugar

Case Is = "Glucose", "Syrup"
' some code here to process glucose or syrup
End Select

' put some generic code here that applies to every row

Next
End With
End Sub

--
Cheers
Nigel



wrote in message
oups.com...
Hi

I am new to Macros and think they are great. I work in food
manufacturing and do a lot of work in costing materials usage etc

Everyday I run a file from my ERP system from work and generate it as
an excel file.

I then do loads of calculations based on aggregating the financial
costs of items so for instance I may want to look at 'ingredients' by
aggregating jam, sugar, glucose etc. The trouble is that these items
are not necessarily on the same row each time I run the report from my
ERP. Is there anyway I can create a macro that will locate and
calculate the materials by their names rather than a cell reference?

Regards

Brian



  #3   Report Post  
Posted to microsoft.public.excel.programming
external usenet poster
 
Posts: 789
Default Macro referencing identical text

Hi
Yes it can be done, using the Find Method to locate the text and from
there using offset to locate the numbers you want. It might also be
possible using AutoFilter and use of the SumTotal worksheet function
without using macros.
Impossible to give any more detail or decide on the best approach
without seeing how your Excel sheet(s?) is laid out and exactly what
calculations you need to do.
regards
Paul

wrote:
Hi

I am new to Macros and think they are great. I work in food
manufacturing and do a lot of work in costing materials usage etc

Everyday I run a file from my ERP system from work and generate it as
an excel file.

I then do loads of calculations based on aggregating the financial
costs of items so for instance I may want to look at 'ingredients' by
aggregating jam, sugar, glucose etc. The trouble is that these items
are not necessarily on the same row each time I run the report from my
ERP. Is there anyway I can create a macro that will locate and
calculate the materials by their names rather than a cell reference?

Regards

Brian


  #4   Report Post  
Posted to microsoft.public.excel.programming
external usenet poster
 
Posts: 5
Default Macro referencing identical text

Hi Nigel

Thanks for your kind help. It seems a bit over my head but will give it
a go

Cheers

Brian
Nigel wrote:
A simple way, assuming that your data is stored in single rows, would be to
scan all rows and using some reference cell that contains the name of the
product, you then run a set of code.

Something like.....

Sub Test()
Dim xRow As Long, xLastRow As Long
With Sheets("Sheet1")
xLastRow = .Cells(Rows.Count, 1).End(xlUp).Row

For xRow = 1 To xLastRow
' put some generic code here that applies to every row

Select Case .Cells(xRow, 1)

Case Is = "Jam"
' some code here to process jam

Case Is = "Sugar"
' some code her to process sugar

Case Is = "Glucose", "Syrup"
' some code here to process glucose or syrup
End Select

' put some generic code here that applies to every row

Next
End With
End Sub

--
Cheers
Nigel



wrote in message
oups.com...
Hi

I am new to Macros and think they are great. I work in food
manufacturing and do a lot of work in costing materials usage etc

Everyday I run a file from my ERP system from work and generate it as
an excel file.

I then do loads of calculations based on aggregating the financial
costs of items so for instance I may want to look at 'ingredients' by
aggregating jam, sugar, glucose etc. The trouble is that these items
are not necessarily on the same row each time I run the report from my
ERP. Is there anyway I can create a macro that will locate and
calculate the materials by their names rather than a cell reference?

Regards

Brian


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 to add different characters to identical data in a column ? Steve Excel Worksheet Functions 4 December 15th 06 10:33 PM
Macro Which Highlights Rows That Contain Identical First Cells luu980[_4_] Excel Programming 4 April 14th 06 02:03 PM
Counting number of identical values (or text) in a range Excelerate-nl Excel Programming 0 September 29th 05 09:42 AM
Macro works, identical Function doesn't....why? Paul S Excel Programming 4 September 12th 05 11:46 AM
Inexplicable difference in row hiding speed - identical code, identical machines! Matt Larkin Excel Programming 5 November 1st 04 10:35 AM


All times are GMT +1. The time now is 02:32 AM.

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

About Us

"It's about Microsoft Excel"