Reply
 
LinkBack Thread Tools Search this Thread Display Modes
  #1   Report Post  
Posted to microsoft.public.excel.programming
external usenet poster
 
Posts: 13
Default passing column character as subroutine parameter

I want to pass a column character as parameter to subroutine. What
should I define it as? Also how can I use that inside subroutine?

For example, the API the subroutine should look like is as below:

formatColumn("C") - Should format column C as per defined in the
subroutine. I'm also not clear how I can use this "C" inside
subroutine to identify which column it is. I'm just requested to have
function such as this.

Any suggestions appreciated.

thanks,
Anand.
  #2   Report Post  
Posted to microsoft.public.excel.programming
external usenet poster
 
Posts: 11,058
Default passing column character as subroutine parameter

Sub main()
Dim s As String
s = "D:D"
Call adjustcolumn(s)
End Sub


Sub adjustcolumn(icl As String)
Columns(icl).ColumnWidth = 30
End Sub

We could have made that that passed an integer, but I like your idea better.
Passing a string allows the subroutine to adjust moe than one column at a
time.
--
Gary''s Student - gsnu2007i


"Anand" wrote:

I want to pass a column character as parameter to subroutine. What
should I define it as? Also how can I use that inside subroutine?

For example, the API the subroutine should look like is as below:

formatColumn("C") - Should format column C as per defined in the
subroutine. I'm also not clear how I can use this "C" inside
subroutine to identify which column it is. I'm just requested to have
function such as this.

Any suggestions appreciated.

thanks,
Anand.

  #3   Report Post  
Posted to microsoft.public.excel.programming
external usenet poster
 
Posts: 421
Default passing column character as subroutine parameter

Hi Anand,

Try something like:

'==========
Public Sub Macro1()
Dim sCol As String

sCol = "C"
Call Macro2(sCol)

End Sub

'----------
Public Sub Macro2(sColumn As String)
Dim Rng As Range

Set Rng = ActiveSheet.Columns(sColumn)
MsgBox Rng.Address

End Sub
'<<==========



---
Regards.
Norman
"Anand" wrote in message
...
I want to pass a column character as parameter to subroutine. What
should I define it as? Also how can I use that inside subroutine?

For example, the API the subroutine should look like is as below:

formatColumn("C") - Should format column C as per defined in the
subroutine. I'm also not clear how I can use this "C" inside
subroutine to identify which column it is. I'm just requested to have
function such as this.

Any suggestions appreciated.

thanks,
Anand.


  #4   Report Post  
Posted to microsoft.public.excel.programming
external usenet poster
 
Posts: 13
Default passing column character as subroutine parameter

On May 23, 3:38 pm, Gary''s Student
wrote:
Sub main()
Dim s As String
s = "D:D"
Call adjustcolumn(s)
End Sub

Sub adjustcolumn(icl As String)
Columns(icl).ColumnWidth = 30
End Sub

We could have made that that passed an integer, but I like your idea better.
Passing a string allows the subroutine to adjust moe than one column at a
time.
--
Gary''s Student - gsnu2007i

"Anand" wrote:
I want to pass a column character as parameter to subroutine. What
should I define it as? Also how can I use that inside subroutine?


For example, the API the subroutine should look like is as below:


formatColumn("C") - Should format column C as per defined in the
subroutine. I'm also not clear how I can use this "C" inside
subroutine to identify which column it is. I'm just requested to have
function such as this.


Any suggestions appreciated.


thanks,
Anand.



Is there a way I can get the column number from the column passed as
string?

thanks,
Anand.
  #5   Report Post  
Posted to microsoft.public.excel.programming
external usenet poster
 
Posts: 13
Default passing column character as subroutine parameter

On May 23, 4:03 pm, Anand wrote:
On May 23, 3:38 pm, Gary''s Student



wrote:
Sub main()
Dim s As String
s = "D:D"
Call adjustcolumn(s)
End Sub


Sub adjustcolumn(icl As String)
Columns(icl).ColumnWidth = 30
End Sub


We could have made that that passed an integer, but I like your idea better.
Passing a string allows the subroutine to adjust moe than one column at a
time.
--
Gary''s Student - gsnu2007i


"Anand" wrote:
I want to pass a column character as parameter to subroutine. What
should I define it as? Also how can I use that inside subroutine?


For example, the API the subroutine should look like is as below:


formatColumn("C") - Should format column C as per defined in the
subroutine. I'm also not clear how I can use this "C" inside
subroutine to identify which column it is. I'm just requested to have
function such as this.


Any suggestions appreciated.


thanks,
Anand.


Is there a way I can get the column number from the column passed as
string?

thanks,
Anand.


got it. Columns("AA").column.

thanks,
Anand.
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
passing ComboBox to subroutine Anand Excel Programming 7 May 9th 08 11:00 PM
Passing ranges to a subroutine [email protected] Excel Programming 1 March 11th 08 03:15 AM
Passing Module to subroutine SixSigmaGuy[_2_] Excel Programming 2 April 25th 06 10:59 PM
How to pass a workshhet name as a parameter into a subroutine ? yigalb Excel Discussion (Misc queries) 4 January 9th 05 10:28 AM
Passing arrays to a subroutine Braden Craig Excel Programming 4 August 17th 03 05:54 PM


All times are GMT +1. The time now is 06:29 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"