Excel Macro

May 18th, 2005 - 01:00 am ET by Lang | Report spam
Hi,

I have a macro and hard code the row numbers to call 10
other macros as below (the first macro starts at row 10).

If intRowNumber = 10 Then
Call LiborCurveFormat
End If
If intRowNumber = 11 Then
Call SWPTNformat
End If
If intRowNumber = 12 Then
Call CMSFormat
End If
If intRowNumber = 13 Then
Call TB3MFormat
End If
If intRowNumber = 14 Then
Call FHLSFFormat
End If
If intRowNumber = 15 Then
Call LiborCurveFormat
End If
If intRowNumber = 16 Then
Call SWPTNformat
End If
If intRowNumber = 17 Then
Call CMSFormat
End If
If intRowNumber = 18 Then
Call TB3MFormat
End If
If intRowNumber = 19 Then
Call FHLSFFormat
End If


Is there a way for me not to specify the row numbers
instead? I'm new to coding and would appreciate any help.

Thanks!
email Follow the discussionReplies 2 repliesReplies Make a reply

Similar topics

Replies

#1 George Nicholson
May 18th, 2005 - 02:47 pm ET | Report spam
I don't really see of any way to avoid specifying row numbers (unless there
is some criteria in the ActiveCell?), but:

Select Case intRowNumber
Case 10, 15
Call LiborCurveFormat
Case 11, 16
Call SWPTNformat
Case 12, 17
Call CMSFormat
Case 13, 18
Call TB3MFormat
Case 14, 19
Call FHLSFFormat
End Select

Another possible alternative:

Select Case intRowNumber Mod 5
(Mod returns the remainder after division: 10 Mod 5 = 0, 11 Mod 5
= 1)
Then would then use Case 0, Case 1, ...Case 4 in place of the 5
Cases above.

Keep in mind that if your starting row numbers change (but everything
remains in a block), you can manipulate/adjust intRowNumber before the
Select Case so that it is "in sync" with your existing Case values rather
than changing the individual Cases (not that I would recommend it).

HTH,
George Nicholson

Remove 'Junk' from return address.


"Lang" wrote in message
news:070201c55b66$927ec320$
Hi,

I have a macro and hard code the row numbers to call 10
other macros as below (the first macro starts at row 10).

If intRowNumber = 10 Then
Call LiborCurveFormat
End If
If intRowNumber = 11 Then
Call SWPTNformat
End If
If intRowNumber = 12 Then
Call CMSFormat
End If
If intRowNumber = 13 Then
Call TB3MFormat
End If
If intRowNumber = 14 Then
Call FHLSFFormat
End If
If intRowNumber = 15 Then
Call LiborCurveFormat
End If
If intRowNumber = 16 Then
Call SWPTNformat
End If
If intRowNumber = 17 Then
Call CMSFormat
End If
If intRowNumber = 18 Then
Call TB3MFormat
End If
If intRowNumber = 19 Then
Call FHLSFFormat
End If


Is there a way for me not to specify the row numbers
instead? I'm new to coding and would appreciate any help.

Thanks!


Replies Reply to this message
#2 Lang
May 19th, 2005 - 12:56 am ET | Report spam
Thank you very much, George. It helps.

"George Nicholson" wrote:

I don't really see of any way to avoid specifying row numbers (unless there
is some criteria in the ActiveCell?), but:

Select Case intRowNumber
Case 10, 15
Call LiborCurveFormat
Case 11, 16
Call SWPTNformat
Case 12, 17
Call CMSFormat
Case 13, 18
Call TB3MFormat
Case 14, 19
Call FHLSFFormat
End Select

Another possible alternative:

Select Case intRowNumber Mod 5
(Mod returns the remainder after division: 10 Mod 5 = 0, 11 Mod 5
= 1)
Then would then use Case 0, Case 1, ...Case 4 in place of the 5
Cases above.

Keep in mind that if your starting row numbers change (but everything
remains in a block), you can manipulate/adjust intRowNumber before the
Select Case so that it is "in sync" with your existing Case values rather
than changing the individual Cases (not that I would recommend it).

HTH,
George Nicholson

Remove 'Junk' from return address.


"Lang" wrote in message
news:070201c55b66$927ec320$
> Hi,
>
> I have a macro and hard code the row numbers to call 10
> other macros as below (the first macro starts at row 10).
>
> If intRowNumber = 10 Then
> Call LiborCurveFormat
> End If
> If intRowNumber = 11 Then
> Call SWPTNformat
> End If
> If intRowNumber = 12 Then
> Call CMSFormat
> End If
> If intRowNumber = 13 Then
> Call TB3MFormat
> End If
> If intRowNumber = 14 Then
> Call FHLSFFormat
> End If
> If intRowNumber = 15 Then
> Call LiborCurveFormat
> End If
> If intRowNumber = 16 Then
> Call SWPTNformat
> End If
> If intRowNumber = 17 Then
> Call CMSFormat
> End If
> If intRowNumber = 18 Then
> Call TB3MFormat
> End If
> If intRowNumber = 19 Then
> Call FHLSFFormat
> End If
>
>
> Is there a way for me not to specify the row numbers
> instead? I'm new to coding and would appreciate any help.
>
> Thanks!





email Follow the discussion Replies Reply to this message
Help Create a new topicReplies Make a reply
Search Make your own search