Reply
 
LinkBack Thread Tools Search this Thread Display Modes
  #1   Report Post  
Posted to microsoft.public.excel.programming
CLR CLR is offline
external usenet poster
 
Posts: 594
Default Combine two macros using InStr?

Hi All.........

I got a macro from here the other day, (sorry, don't remember who submitted
it), and modified it for my own use. Unfortunately, in order to get all I
want done, I had to turn it into two seperate macros, as shown below. Can
anyone please tell me how these two might be combined into just one
macro?.........or maybe it's not possible?
The only thing I've changed between the two, is the 8 to a 3 in the InStr
statement, to get the thing to read for "Total" in column 3 instead of
column 8. It works fine this way, just aggravating to have to have
two........

====================================
Sub AddRowSubTotalsDomestic()

lastrow = Range("A65536").End(xlUp).Row
For r = 8 To lastrow
If InStr(1, Cells(r, 8).Value, "Total") 0 Then
ActiveSheet.Rows(r + 1).EntireRow.Insert

End If
Next
End Sub

====================================

Sub AddRowSubTotalsInternational()

lastrow = Range("A65536").End(xlUp).Row
For r = 8 To lastrow
If InStr(1, Cells(r, 3).Value, "Total") 0 Then
ActiveSheet.Rows(r + 1).EntireRow.Insert

End If
Next
End Sub
=====================================


Vaya con Dios,
Chuck, CABGx3



  #2   Report Post  
Posted to microsoft.public.excel.programming
external usenet poster
 
Posts: 11,272
Default Combine two macros using InStr?

Sub AddRowSubTotalsBoth()

lastrow = Range("A" & Rows.Count).End(xlUp).Row
For r = 8 To lastrow
If InStr(1, Cells(r, 3).Value, "Total") 0 Or _
InStr(1, Cells(r, 8).Value, "Total") 0 Then
ActiveSheet.Rows(r + 1).EntireRow.Insert

End If
Next
End Sub

--

HTH

Bob Phillips
... looking out across Poole Harbour to the Purbecks
(remove nothere from the email address if mailing direct)

"CLR" wrote in message
...
Hi All.........

I got a macro from here the other day, (sorry, don't remember who

submitted
it), and modified it for my own use. Unfortunately, in order to get all I
want done, I had to turn it into two seperate macros, as shown below.

Can
anyone please tell me how these two might be combined into just one
macro?.........or maybe it's not possible?
The only thing I've changed between the two, is the 8 to a 3 in the InStr
statement, to get the thing to read for "Total" in column 3 instead of
column 8. It works fine this way, just aggravating to have to have
two........

====================================
Sub AddRowSubTotalsDomestic()

lastrow = Range("A65536").End(xlUp).Row
For r = 8 To lastrow
If InStr(1, Cells(r, 8).Value, "Total") 0 Then
ActiveSheet.Rows(r + 1).EntireRow.Insert

End If
Next
End Sub

====================================

Sub AddRowSubTotalsInternational()

lastrow = Range("A65536").End(xlUp).Row
For r = 8 To lastrow
If InStr(1, Cells(r, 3).Value, "Total") 0 Then
ActiveSheet.Rows(r + 1).EntireRow.Insert

End If
Next
End Sub
=====================================


Vaya con Dios,
Chuck, CABGx3





  #3   Report Post  
Posted to microsoft.public.excel.programming
external usenet poster
 
Posts: 2,337
Default Combine two macros using InStr?

Assuming both work as desired just combine with an OR
Sub AddRowSubTotalsDomestic()

lastrow = Range("A65536").End(xlUp).Row
For r = 8 To lastrow
If InStr(1, Cells(r, 8).Value, "Total") 0 _

or instr(1,cells(r,3).value,"Total")) Then
ActiveSheet.Rows(r + 1).EntireRow.Insert

End If
Next
End Sub



--
Don Guillett
SalesAid Software

"CLR" wrote in message
...
Hi All.........

I got a macro from here the other day, (sorry, don't remember who

submitted
it), and modified it for my own use. Unfortunately, in order to get all I
want done, I had to turn it into two seperate macros, as shown below.

Can
anyone please tell me how these two might be combined into just one
macro?.........or maybe it's not possible?
The only thing I've changed between the two, is the 8 to a 3 in the InStr
statement, to get the thing to read for "Total" in column 3 instead of
column 8. It works fine this way, just aggravating to have to have
two........

====================================
Sub AddRowSubTotalsDomestic()

lastrow = Range("A65536").End(xlUp).Row
For r = 8 To lastrow
If InStr(1, Cells(r, 8).Value, "Total") 0 Then
ActiveSheet.Rows(r + 1).EntireRow.Insert

End If
Next
End Sub

====================================

Sub AddRowSubTotalsInternational()

lastrow = Range("A65536").End(xlUp).Row
For r = 8 To lastrow
If InStr(1, Cells(r, 3).Value, "Total") 0 Then
ActiveSheet.Rows(r + 1).EntireRow.Insert

End If
Next
End Sub
=====================================


Vaya con Dios,
Chuck, CABGx3





  #4   Report Post  
Posted to microsoft.public.excel.programming
external usenet poster
 
Posts: 3,885
Default Combine two macros using InStr?

Hi
try
Sub AddRowSubTotalsDomestic()

lastrow = Range("A65536").End(xlUp).Row
For r = 8 To lastrow
If InStr(1, Cells(r, 8).Value, "Total") 0 or InStr(1, Cells(r,
3).Value, "Total") 0 Then
ActiveSheet.Rows(r + 1).EntireRow.Insert

End If
Next
End Sub

--
Regards
Frank Kabel
Frankfurt, Germany

CLR wrote:
Hi All.........

I got a macro from here the other day, (sorry, don't remember who
submitted it), and modified it for my own use. Unfortunately, in
order to get all I want done, I had to turn it into two seperate
macros, as shown below. Can anyone please tell me how these two
might be combined into just one macro?.........or maybe it's not
possible?
The only thing I've changed between the two, is the 8 to a 3 in the
InStr statement, to get the thing to read for "Total" in column 3
instead of column 8. It works fine this way, just aggravating to
have to have two........

====================================
Sub AddRowSubTotalsDomestic()

lastrow = Range("A65536").End(xlUp).Row
For r = 8 To lastrow
If InStr(1, Cells(r, 8).Value, "Total") 0 Then
ActiveSheet.Rows(r + 1).EntireRow.Insert

End If
Next
End Sub

====================================

Sub AddRowSubTotalsInternational()

lastrow = Range("A65536").End(xlUp).Row
For r = 8 To lastrow
If InStr(1, Cells(r, 3).Value, "Total") 0 Then
ActiveSheet.Rows(r + 1).EntireRow.Insert

End If
Next
End Sub
=====================================


Vaya con Dios,
Chuck, CABGx3


  #5   Report Post  
Posted to microsoft.public.excel.programming
external usenet poster
 
Posts: 27,285
Default Combine two macros using InStr?

You macro is flawed. Lastrow does not adjust as you add rows, so if you
have any total near the end of your range, you would miss it.

You should loop from lastrow to 8

Sub AddRowSubTotalsBoth()

lastrow = Range("A" & Rows.Count).End(xlUp).Row
For r = lastrow to 8 step -1
If InStr(1, Cells(r, 3).Value, "Total") 0 Or _
InStr(1, Cells(r, 8).Value, "Total") 0 Then
ActiveSheet.Rows(r + 1).EntireRow.Insert

End If
Next
End Sub

--
Regards,
Tom Ogilvy


--
Regards,
Tom Ogilvy

"CLR" wrote in message
...
Hi All.........

I got a macro from here the other day, (sorry, don't remember who

submitted
it), and modified it for my own use. Unfortunately, in order to get all I
want done, I had to turn it into two seperate macros, as shown below.

Can
anyone please tell me how these two might be combined into just one
macro?.........or maybe it's not possible?
The only thing I've changed between the two, is the 8 to a 3 in the InStr
statement, to get the thing to read for "Total" in column 3 instead of
column 8. It works fine this way, just aggravating to have to have
two........

====================================
Sub AddRowSubTotalsDomestic()

lastrow = Range("A65536").End(xlUp).Row
For r = 8 To lastrow
If InStr(1, Cells(r, 8).Value, "Total") 0 Then
ActiveSheet.Rows(r + 1).EntireRow.Insert

End If
Next
End Sub

====================================

Sub AddRowSubTotalsInternational()

lastrow = Range("A65536").End(xlUp).Row
For r = 8 To lastrow
If InStr(1, Cells(r, 3).Value, "Total") 0 Then
ActiveSheet.Rows(r + 1).EntireRow.Insert

End If
Next
End Sub
=====================================


Vaya con Dios,
Chuck, CABGx3







  #6   Report Post  
Posted to microsoft.public.excel.programming
CLR CLR is offline
external usenet poster
 
Posts: 594
Default Combine two macros using InStr?

Thanks Tom...........

Of course I haven't a clue about what you're talking about..........but if
you say so, it's gospel. I'll make your recommended changes, and thanks
again.

Vaya con Dios,
Chuck, CABGx3




"Tom Ogilvy" wrote in message
...
You macro is flawed. Lastrow does not adjust as you add rows, so if you
have any total near the end of your range, you would miss it.

You should loop from lastrow to 8

Sub AddRowSubTotalsBoth()

lastrow = Range("A" & Rows.Count).End(xlUp).Row
For r = lastrow to 8 step -1
If InStr(1, Cells(r, 3).Value, "Total") 0 Or _
InStr(1, Cells(r, 8).Value, "Total") 0 Then
ActiveSheet.Rows(r + 1).EntireRow.Insert

End If
Next
End Sub

--
Regards,
Tom Ogilvy


--
Regards,
Tom Ogilvy

"CLR" wrote in message
...
Hi All.........

I got a macro from here the other day, (sorry, don't remember who

submitted
it), and modified it for my own use. Unfortunately, in order to get all

I
want done, I had to turn it into two seperate macros, as shown below.

Can
anyone please tell me how these two might be combined into just one
macro?.........or maybe it's not possible?
The only thing I've changed between the two, is the 8 to a 3 in the

InStr
statement, to get the thing to read for "Total" in column 3 instead of
column 8. It works fine this way, just aggravating to have to have
two........

====================================
Sub AddRowSubTotalsDomestic()

lastrow = Range("A65536").End(xlUp).Row
For r = 8 To lastrow
If InStr(1, Cells(r, 8).Value, "Total") 0 Then
ActiveSheet.Rows(r + 1).EntireRow.Insert

End If
Next
End Sub

====================================

Sub AddRowSubTotalsInternational()

lastrow = Range("A65536").End(xlUp).Row
For r = 8 To lastrow
If InStr(1, Cells(r, 3).Value, "Total") 0 Then
ActiveSheet.Rows(r + 1).EntireRow.Insert

End If
Next
End Sub
=====================================


Vaya con Dios,
Chuck, CABGx3








  #7   Report Post  
Posted to microsoft.public.excel.programming
CLR CLR is offline
external usenet poster
 
Posts: 594
Default Combine two macros using InStr?

Thanks Tom...........

Of course I haven't a clue about what you're talking about..........but if
you say so, it's gospel. I'll make your recommended changes, and thanks
again.

Vaya con Dios,
Chuck, CABGx3




"Tom Ogilvy" wrote in message
...
You macro is flawed. Lastrow does not adjust as you add rows, so if you
have any total near the end of your range, you would miss it.

You should loop from lastrow to 8

Sub AddRowSubTotalsBoth()

lastrow = Range("A" & Rows.Count).End(xlUp).Row
For r = lastrow to 8 step -1
If InStr(1, Cells(r, 3).Value, "Total") 0 Or _
InStr(1, Cells(r, 8).Value, "Total") 0 Then
ActiveSheet.Rows(r + 1).EntireRow.Insert

End If
Next
End Sub

--
Regards,
Tom Ogilvy


--
Regards,
Tom Ogilvy

"CLR" wrote in message
...
Hi All.........

I got a macro from here the other day, (sorry, don't remember who

submitted
it), and modified it for my own use. Unfortunately, in order to get all

I
want done, I had to turn it into two seperate macros, as shown below.

Can
anyone please tell me how these two might be combined into just one
macro?.........or maybe it's not possible?
The only thing I've changed between the two, is the 8 to a 3 in the

InStr
statement, to get the thing to read for "Total" in column 3 instead of
column 8. It works fine this way, just aggravating to have to have
two........

====================================
Sub AddRowSubTotalsDomestic()

lastrow = Range("A65536").End(xlUp).Row
For r = 8 To lastrow
If InStr(1, Cells(r, 8).Value, "Total") 0 Then
ActiveSheet.Rows(r + 1).EntireRow.Insert

End If
Next
End Sub

====================================

Sub AddRowSubTotalsInternational()

lastrow = Range("A65536").End(xlUp).Row
For r = 8 To lastrow
If InStr(1, Cells(r, 3).Value, "Total") 0 Then
ActiveSheet.Rows(r + 1).EntireRow.Insert

End If
Next
End Sub
=====================================


Vaya con Dios,
Chuck, CABGx3








"Tom Ogilvy" wrote in message
...
You macro is flawed. Lastrow does not adjust as you add rows, so if you
have any total near the end of your range, you would miss it.

You should loop from lastrow to 8

Sub AddRowSubTotalsBoth()

lastrow = Range("A" & Rows.Count).End(xlUp).Row
For r = lastrow to 8 step -1
If InStr(1, Cells(r, 3).Value, "Total") 0 Or _
InStr(1, Cells(r, 8).Value, "Total") 0 Then
ActiveSheet.Rows(r + 1).EntireRow.Insert

End If
Next
End Sub

--
Regards,
Tom Ogilvy


--
Regards,
Tom Ogilvy

"CLR" wrote in message
...
Hi All.........

I got a macro from here the other day, (sorry, don't remember who

submitted
it), and modified it for my own use. Unfortunately, in order to get all

I
want done, I had to turn it into two seperate macros, as shown below.

Can
anyone please tell me how these two might be combined into just one
macro?.........or maybe it's not possible?
The only thing I've changed between the two, is the 8 to a 3 in the

InStr
statement, to get the thing to read for "Total" in column 3 instead of
column 8. It works fine this way, just aggravating to have to have
two........

====================================
Sub AddRowSubTotalsDomestic()

lastrow = Range("A65536").End(xlUp).Row
For r = 8 To lastrow
If InStr(1, Cells(r, 8).Value, "Total") 0 Then
ActiveSheet.Rows(r + 1).EntireRow.Insert

End If
Next
End Sub

====================================

Sub AddRowSubTotalsInternational()

lastrow = Range("A65536").End(xlUp).Row
For r = 8 To lastrow
If InStr(1, Cells(r, 3).Value, "Total") 0 Then
ActiveSheet.Rows(r + 1).EntireRow.Insert

End If
Next
End Sub
=====================================


Vaya con Dios,
Chuck, CABGx3







  #8   Report Post  
Posted to microsoft.public.excel.programming
CLR CLR is offline
external usenet poster
 
Posts: 594
Default Combine two macros using InStr?

Thank you Don and Bob, and Frank...........that was exactly what I was
looking for

Vaya con Dios
Chuck, CABGx3


"CLR" wrote in message
...
Hi All.........

I got a macro from here the other day, (sorry, don't remember who

submitted
it), and modified it for my own use. Unfortunately, in order to get all I
want done, I had to turn it into two seperate macros, as shown below.

Can
anyone please tell me how these two might be combined into just one
macro?.........or maybe it's not possible?
The only thing I've changed between the two, is the 8 to a 3 in the InStr
statement, to get the thing to read for "Total" in column 3 instead of
column 8. It works fine this way, just aggravating to have to have
two........

====================================
Sub AddRowSubTotalsDomestic()

lastrow = Range("A65536").End(xlUp).Row
For r = 8 To lastrow
If InStr(1, Cells(r, 8).Value, "Total") 0 Then
ActiveSheet.Rows(r + 1).EntireRow.Insert

End If
Next
End Sub

====================================

Sub AddRowSubTotalsInternational()

lastrow = Range("A65536").End(xlUp).Row
For r = 8 To lastrow
If InStr(1, Cells(r, 3).Value, "Total") 0 Then
ActiveSheet.Rows(r + 1).EntireRow.Insert

End If
Next
End Sub
=====================================


Vaya con Dios,
Chuck, CABGx3





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
Combine macros variable help Ephraim Excel Worksheet Functions 2 March 21st 10 01:52 PM
combine two macros puiuluipui Excel Discussion (Misc queries) 4 May 21st 09 10:30 AM
How do I combine MACROS and functions? Mr_Crowe New Users to Excel 1 July 9th 08 02:23 AM
combine two macros Lisa Excel Worksheet Functions 1 July 20th 06 02:10 AM
Combine 2 macros Steph[_3_] Excel Programming 0 January 20th 04 03:05 PM


All times are GMT +1. The time now is 09:17 AM.

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"