+ Reply to Thread
Results 1 to 15 of 15

Selecting cells between blanks

  1. #1
    Registered User
    Join Date
    10-23-2013
    Location
    United Kingdom
    MS-Off Ver
    Excel 2010
    Posts
    8

    Selecting cells between blanks

    Hi Guys - hope you can help as I've been pulling my hair out.

    I've got a list of names + addresses separated by an empty cell all in column A e.g

    A1 - Mr B Bloggs
    A2 - 1 High Street
    A3 - Lowtown
    A4 - LT1 1HJ
    A5 -
    A6 -Mrs J Jones
    A7 -10 Upper Road
    A8 -Upsville
    A9 - UP1 5TG

    ... and so on, about 1000+ addresses some over 2 rows, some over 5.

    What I've been (unsuccessfully) trying is to loop through column A pick up a name and address and Transpose paste it starting in column B then repeat. Once complete, delete column A so I'm left with normalised data.
    I've got the pasting bit nailed down, it's just the selecting, copying and looping bit that I'm struggling with.

    Any help would be greatly appreciated.

    Cheers

  2. #2
    Forum Expert daffodil11's Avatar
    Join Date
    07-11-2013
    Location
    Phoenixville, PA
    MS-Off Ver
    MS Office 2016
    Posts
    4,465

    Re: Selecting cells between blanks

    Could probably do it better with Visual Basic coding, but this should get you off in the right direction.

    First, insert a row at the top to create a blank value in A1.

    Then, in B2 paste:

    =IF(AND($A1="",$A2<>"",A2<>"",INDIRECT("$A"&COLUMN(C1)+(ROWS($A$1:A1)-1))<>0),INDIRECT("$A"&COLUMN(C1)+(ROWS($A$1:A1)-1)),"")

    And copy that out across as many columns and down as many rows as needed.

    Edit: Missed the rows offset. All fixed.
    Last edited by daffodil11; 12-10-2013 at 12:11 PM. Reason: Rows Offset
    Make Mom proud: Add to my reputation if I helped out!

    Make the Moderators happy: Mark the Thread as Solved if your question was answered!

  3. #3
    Registered User
    Join Date
    10-23-2013
    Location
    United Kingdom
    MS-Off Ver
    Excel 2010
    Posts
    8

    Re: Selecting cells between blanks

    Really sorry - I should have said I was using VBA to try and achieve this - my bad.

  4. #4
    Forum Expert daffodil11's Avatar
    Join Date
    07-11-2013
    Location
    Phoenixville, PA
    MS-Off Ver
    MS Office 2016
    Posts
    4,465

    Re: Selecting cells between blanks

    I'd recommend messaging a moderator to request having your post moved over the the VB Forum where the code monkeys play.

    At the very least, I'm sure the above logic could be converted into VB.

    My code is pretty bad and I'd probably do it using For Each Cell, a Loop, a lot of Application.Function and closing with setting cell values to value to kill the formulas. I tend to accomplish in 75-100 lines what most people can do in 10-15.



    tranpositions.xlsx

  5. #5
    Registered User
    Join Date
    10-23-2013
    Location
    United Kingdom
    MS-Off Ver
    Excel 2010
    Posts
    8

    Re: Selecting cells between blanks

    Thanks for trying - really appreciated.

  6. #6
    Forum Contributor arlu1201's Avatar
    Join Date
    09-09-2011
    Location
    Bangalore, India
    MS-Off Ver
    Excel 2003 & 2007
    Posts
    19,166

    Re: Selecting cells between blanks

    Thread moved to the VBA / Programming subforum.
    If I have helped, Don't forget to add to my reputation (click on the star below the post)
    Don't forget to mark threads as "Solved" (Thread Tools->Mark thread as Solved)
    Use code tags when posting your VBA code: [code] Your code here [/code]

  7. #7
    Forum Expert
    Join Date
    10-06-2008
    Location
    Canada
    MS-Off Ver
    2007 / 2013
    Posts
    5,522

    Re: Selecting cells between blanks

    Are these all blocks of 4, space, block of 4, space etc etc?

  8. #8
    Valued Forum Contributor adyteo's Avatar
    Join Date
    01-10-2013
    Location
    Calgary
    MS-Off Ver
    Excel 2010
    Posts
    540

    Re: Selecting cells between blanks

    I have 5 columns: Full Details (your column A), Name, Street, City, Postal Code.
    I assumed there are blocks of 4 plus one empty row.
    this is the macro:
    Please Login or Register  to view this content.

  9. #9
    Forum Expert
    Join Date
    10-06-2008
    Location
    Canada
    MS-Off Ver
    2007 / 2013
    Posts
    5,522

    Re: Selecting cells between blanks

    Or this (If they are blocks of 4, you could try this on a copy of your workbook.)

    Please Login or Register  to view this content.

  10. #10
    Forum Guru
    Join Date
    08-15-2004
    Location
    Tokyo, Japan
    MS-Off Ver
    2013 O.365
    Posts
    22,523

    Re: Selecting cells between blanks

    Perhaps
    Please Login or Register  to view this content.

  11. #11
    Registered User
    Join Date
    10-23-2013
    Location
    United Kingdom
    MS-Off Ver
    Excel 2010
    Posts
    8

    Re: Selecting cells between blanks

    Hi

    No - There can be a block of 4 then a block of 5 then 2 and so on.

  12. #12
    Registered User
    Join Date
    10-23-2013
    Location
    United Kingdom
    MS-Off Ver
    Excel 2010
    Posts
    8

    Re: Selecting cells between blanks

    Quote Originally Posted by jindon View Post
    Perhaps
    Please Login or Register  to view this content.
    jindon - you are an absolute star, been struggling with this for a while

    Cheers

  13. #13
    Valued Forum Contributor adyteo's Avatar
    Join Date
    01-10-2013
    Location
    Calgary
    MS-Off Ver
    Excel 2010
    Posts
    540

    Re: Selecting cells between blanks

    Then how do you know if, for example, on row 2 of the group is the Postal Code or the Street name?

  14. #14
    Registered User
    Join Date
    10-23-2013
    Location
    United Kingdom
    MS-Off Ver
    Excel 2010
    Posts
    8

    Re: Selecting cells between blanks

    Quote Originally Posted by adyteo View Post
    Then how do you know if, for example, on row 2 of the group is the Postal Code or the Street name?
    I don't - the column heading will be simply Add_Line1, Add_line2 and so on. Word's Mail Merge will deal with any blank entries in the worksheet.

  15. #15
    Forum Guru
    Join Date
    08-15-2004
    Location
    Tokyo, Japan
    MS-Off Ver
    2013 O.365
    Posts
    22,523

    Re: Selecting cells between blanks

    Can you mark this thread as "Solved", if you are happy with the solution provided?

+ 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. Replies: 1
    Last Post: 10-24-2012, 01:21 PM
  2. Count cells without blank cells or space blanks
    By Zaeguzah in forum Excel General
    Replies: 12
    Last Post: 03-04-2010, 07:03 AM
  3. Selecting Cells between blanks for use in graphs.
    By prefix in forum Excel Programming / VBA / Macros
    Replies: 16
    Last Post: 09-21-2009, 10:04 AM
  4. selecting all blanks in multiple columns, then deleting those rows
    By DSSdiva in forum Excel Programming / VBA / Macros
    Replies: 6
    Last Post: 05-12-2005, 10:06 AM
  5. Replies: 5
    Last Post: 02-21-2005, 01:06 PM

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