ExcelBanter

ExcelBanter (https://www.excelbanter.com/)
-   Excel Programming (https://www.excelbanter.com/excel-programming/)
-   -   Passing Info Between Macros (https://www.excelbanter.com/excel-programming/371491-passing-info-between-macros.html)

Rob

Passing Info Between Macros
 
I have a Dim that us the same in multiple macros shown below

Dim RowID
RowID = ActiveCell.Row


How do I use the same RowID in the Original Sub and when it's done running
it passes the same value of RowID to the next sub?

Originating Sub - InsertSection()
2nd Sub - SetBorders()
3rd Sub - InsertFormulas()
4th Sub - AddText()
5th Sub - SetColors()
6th Sub - ConditionalFormatting()
7th Sub - SetNames()

There's more but you get the point. All of them start off with the very same
Dim shown above and they all end with the same Range Selection

Range("A" & RowID).Select

Any help would be awesome.

Thanks in Advance.
Rob

Gary''s Student

Passing Info Between Macros
 
Dim RowID before any of the macros in the module. That way it will be global
to the macros. One macro can set it and the others see its value.
--
Gary's Student


"Rob" wrote:

I have a Dim that us the same in multiple macros shown below

Dim RowID
RowID = ActiveCell.Row


How do I use the same RowID in the Original Sub and when it's done running
it passes the same value of RowID to the next sub?

Originating Sub - InsertSection()
2nd Sub - SetBorders()
3rd Sub - InsertFormulas()
4th Sub - AddText()
5th Sub - SetColors()
6th Sub - ConditionalFormatting()
7th Sub - SetNames()

There's more but you get the point. All of them start off with the very same
Dim shown above and they all end with the same Range Selection

Range("A" & RowID).Select

Any help would be awesome.

Thanks in Advance.
Rob


Rob

Passing Info Between Macros
 
I didn't know you could do that?? What about the Subs that need to use a
different value for RowID?

"Gary''s Student" wrote:

Dim RowID before any of the macros in the module. That way it will be global
to the macros. One macro can set it and the others see its value.
--
Gary's Student


"Rob" wrote:

I have a Dim that us the same in multiple macros shown below

Dim RowID
RowID = ActiveCell.Row


How do I use the same RowID in the Original Sub and when it's done running
it passes the same value of RowID to the next sub?

Originating Sub - InsertSection()
2nd Sub - SetBorders()
3rd Sub - InsertFormulas()
4th Sub - AddText()
5th Sub - SetColors()
6th Sub - ConditionalFormatting()
7th Sub - SetNames()

There's more but you get the point. All of them start off with the very same
Dim shown above and they all end with the same Range Selection

Range("A" & RowID).Select

Any help would be awesome.

Thanks in Advance.
Rob



All times are GMT +1. The time now is 04:36 AM.

Powered by vBulletin® Copyright ©2000 - 2025, Jelsoft Enterprises Ltd.
ExcelBanter.com