+ Reply to Thread
Results 1 to 9 of 9

Importing selected cells into VBA

Hybrid View

  1. #1
    Valued Forum Contributor
    Join Date
    11-16-2004
    Location
    Devon UK
    MS-Off Ver
    2010
    Posts
    357

    Importing selected cells into VBA

    Can you help with how to import into vba just the data in the currently selected cells?

    What I want to do is to manually select a range of rows (in a single column) and upon running the macro put the data from each cell into the uppermost cell with each seperated with a comma.

    I can manage the combining of the data but don't now the selection is read into VBA
    Last edited by tryer; 10-13-2008 at 03:06 PM.

  2. #2
    Forum Contributor VBA Noob's Avatar
    Join Date
    04-25-2006
    Location
    London, England
    MS-Off Ver
    xl03 & xl 07(Jan 09)
    Posts
    11,988
    manually select a range of rows (in a single column)
    Do you mean a range of cells in one column

    VBA Noob
    _________________________________________


    Credo Elvem ipsum etian vivere
    _________________________________________
    A message for cross posters

    Please remember to wrap code.

    Forum Rules

    Please add to your signature if you found this link helpful. Excel links !!!

  3. #3
    Valued Forum Contributor
    Join Date
    11-16-2004
    Location
    Devon UK
    MS-Off Ver
    2010
    Posts
    357
    Yes, sorry if I didn't explain clearly

  4. #4
    Forum Contributor VBA Noob's Avatar
    Join Date
    04-25-2006
    Location
    London, England
    MS-Off Ver
    xl03 & xl 07(Jan 09)
    Posts
    11,988
    See if this helps

    Dim c As Range
    Dim NewSrt As String
        For Each c In Selection
            NewSrt = NewSrt & "," & c.Value
        Next
    Selection(1).Value = Mid(NewSrt, 2, 9 ^ 9)
    VBA Noob

  5. #5
    Valued Forum Contributor
    Join Date
    11-16-2004
    Location
    Devon UK
    MS-Off Ver
    2010
    Posts
    357
    Thanks Noob that works a treat.

    Is there a way to delete the cells below selection(1) ? at the same time?

  6. #6
    Forum Contributor VBA Noob's Avatar
    Join Date
    04-25-2006
    Location
    London, England
    MS-Off Ver
    xl03 & xl 07(Jan 09)
    Posts
    11,988
    Add
    c.Clear
    after
    NewSrt = NewSrt & "," & c.Value
    VBA Noob

  7. #7
    Valued Forum Contributor
    Join Date
    11-16-2004
    Location
    Devon UK
    MS-Off Ver
    2010
    Posts
    357

    trying to understand

    Noob this works perfectly. However I'm struggling to understand the line
    Selection(1).Value = Mid(NewSrt, 2, 9 ^ 9)
    presumably Selection (1) selects the first cell in the range but don't know what the 9^9 bit does?

+ Reply to Thread

Thread Information

Users Browsing this Thread

There are currently 1 users browsing this thread. (0 members and 1 guests)

Similar Threads

  1. average of cells from user selected range of worksheets
    By ge0rge in forum Excel Programming / VBA / Macros
    Replies: 3
    Last Post: 09-05-2008, 07:34 AM
  2. bug: cells selected as mouse moves
    By urungus in forum Excel General
    Replies: 5
    Last Post: 08-28-2008, 09:39 PM
  3. Manual calculating selected cells only
    By pauldaddyadams in forum Excel Programming / VBA / Macros
    Replies: 5
    Last Post: 06-11-2008, 04:05 AM
  4. importing text but it spreads across cells
    By robin.a in forum Excel General
    Replies: 2
    Last Post: 10-15-2006, 12:36 AM

Bookmarks

Posting Permissions

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

Search Engine Friendly URLs by vBSEO 3.6.0 RC 1