+ Reply to Thread
Results 1 to 9 of 9

Importing selected cells into VBA

Hybrid View

tryer Importing selected cells into... 10-12-2008, 05:00 PM
VBA Noob Do you mean a range of cells... 10-12-2008, 05:16 PM
tryer Yes, sorry if I didn't... 10-12-2008, 05:21 PM
VBA Noob See if this helps Dim c... 10-12-2008, 05:23 PM
tryer Thanks Noob that works a... 10-12-2008, 05:45 PM
VBA Noob Add c.Clear after NewSrt... 10-12-2008, 05:46 PM
tryer trying to understand 10-12-2008, 05:48 PM
VBA Noob I use the mid function to get... 10-12-2008, 05:52 PM
tryer Thanks that's great :) 10-12-2008, 05:54 PM
  1. #1
    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
    _________________________________________


    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 !!!

  2. #2
    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?

  3. #3
    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

  4. #4
    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?

  5. #5
    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
    I use the mid function to get rid of the extra comma at the start.
    Type =9^9 in a cell and it returns 387420489. This makes sure it shouldn't cut off any cells at the end of the mid function

    Selection (1) selects the first cell in the range
    Correct

    VBA Noob

  6. #6
    Valued Forum Contributor
    Join Date
    11-16-2004
    Location
    Devon UK
    MS-Off Ver
    2010
    Posts
    357
    Thanks that's great

+ 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