Results 1 to 2 of 2

Thread: VBA with EXCEL

  1. #1

    Thread Starter
    Addicted Member icemanmt78's Avatar
    Join Date
    May 2000
    Posts
    142

    Angry

    I want to write a macro that works as follows.

    A user selects any number of cells and then uses a command button to execute a procedure.

    How do i get the proceudure to execute only on the cells selected by the user.

    Cheers


  2. #2
    I'm about to be a PowerPoster! Joacim Andersson's Avatar
    Join Date
    Jan 1999
    Location
    Sweden
    Posts
    14,649
    You could use code simular to this:
    Code:
        Dim rng As Range
        Dim iCount As Integer
        Dim r As Integer, c As Integer
        
        Set rng = Selection
        For r = 1 To rng.Cells.Rows.Count
            For c = 1 To rng.Cells.Columns.Count
                iCount = iCount + 1
                rng(r, c) = "Cell #" & iCount
            Next
        Next
    Good luck!

Posting Permissions

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



Click Here to Expand Forum to Full Width