Reply
 
LinkBack Thread Tools Search this Thread Display Modes
  #1   Report Post  
Posted to microsoft.public.excel.programming
external usenet poster
 
Posts: 5,441
Default Passing Arguments

Grant,

Assuming you want the column letters, like "AA":

Sub LastColumn()
Dim strLastCol As String
strLastCol = FindLastCol(10, "Sheet 1")
ActiveCell.Formula = strLastCol
End Sub

Public Function FindLastCol(myR As Long, mySh As String) As String
FindLastCol = ColLet(Worksheets(mySh).Cells(myR,
256).End(xlToLeft).Column)
End Function

Function ColLet(ColNum As Integer) As String
If ColNum 26 Then ColLet = Chr((ColNum - 1) \ 26 + 64)
ColLet = ColLet & Chr(((ColNum - 1) Mod 26) + 65)
End Function


--
HTH,
Bernie
MS Excel MVP
"Grant Reid" wrote in message
...
Hi

I need to apply a similar methodology to determine the last column in a
given worksheet. Once again, assume that I have button on Sheet1.

I want to attach the LastColumn macro to this button. What I'm attempting

to
establish is to find the last column in a range but on a different sheet,

so
I'll need to pass both the starting cell address and the sheet name eg;

Sub LastColumn
Dim strLastCol As String
strLastCol = FindLastCol("B10", "Sheet 1")
ActiveCell.Formula = strLastCol
End Sub

Its the called function FindLastCol, that I'm battling with. Can anyone

help
fill in the blanks?

Public Function FindLastCol(??????????, mySh As String) As String
FindLastCol = Worksheets(mySh).??????????????
End Function

Many Thanks - Grant




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 Arguments in Excell UB Excel Worksheet Functions 3 February 13th 07 04:08 PM
Passing Arguments in Excell function UB Excel Discussion (Misc queries) 2 February 13th 07 03:19 PM
Passing Variable Number of Arguments to a Sub blatham Excel Discussion (Misc queries) 4 December 10th 05 10:36 AM
Passing arguments to a sub routine... Jeff Harbin[_2_] Excel Programming 2 January 29th 04 03:25 AM
Passing ARGUMENTS between event procedures of a USERFORM jason Excel Programming 8 November 10th 03 07:36 PM


All times are GMT +1. The time now is 03:32 PM.

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"