Get column numbers of first and last columns in selected ran - Page 2
Thanks Thanks:  0
Likes Likes:  0
Page 2 of 2 FirstFirst 12
Results 11 to 12 of 12

Thread: Get column numbers of first and last columns in selected ran

  1. #11
    MrExcel MVP Al Chara's Avatar
    Join Date
    Feb 2002
    Location
    Newark, Delaware
    Posts
    1,701
    Post Thanks / Like
    Mentioned
    0 Post(s)
    Tagged
    0 Thread(s)

    Default

     
    On 2002-04-18 07:25, Abdc wrote:
    For Al Chara's code, you need to Dim the LastCol and First Col As String (as opposed to Bertie Bagshot's code which is "dimmed" as Integer).
    You are right. Sorry, mistype on my part. It should read:
    Dim FirstCol As String, LastCol As String

    Best regards,
    Allan Chara
    http://www.mrspreadsheets.com

  2. #12

    Join Date
    Mar 2002
    Posts
    20
    Post Thanks / Like
    Mentioned
    0 Post(s)
    Tagged
    0 Thread(s)

    Default

      
    On 2002-04-18 07:34, nisht wrote:
    sub firstlastcolumn ()
    dim intfirstcolumn as integer
    dim intlastcolumn as integer
    dim i as integer
    ' you need to make selection now..

    ' or you can select current region

    ' currentregion.select

    intfirstcolumn = Activecell.column
    intlastcolumn = selection.column.count + intfirstcolumn

    ' you can step for to get operation by leaving one column or two column.
    for i = intfirstcolumn to intlastcolumn

    cells(1,i) = "Put your operation."

    next i

    end sub


    ni****h desai
    http://www.pexcel.com

    Your code only works if the active cell happens to be in the first column of the selected range.
    Bertie Bagshot's code (FirstCol = Selection(1, 1).Column) works regardless of the active cell location.
    In any event, Visions_Fugitive has already said that his macro is working.





User Tag List

Like this thread? Share it with others

Like this thread? Share it with others

Posting Permissions

  • You may not post new threads
  • You may not post replies
  • You may not post attachments
  • You may not edit your posts
  •  

 

 
DMCA.com