Thread
:
Combine two macros using InStr?
View Single Post
#
2
Posted to microsoft.public.excel.programming
Don Guillett[_4_]
external usenet poster
Posts: 2,337
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
Reply With Quote
Don Guillett[_4_]
View Public Profile
Find all posts by Don Guillett[_4_]