+ Reply to Thread
Results 1 to 9 of 9

Fill Blanks

  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

    Fill Blanks

    Hi VBA experts,

    I want some VBA code to replace the Fill blanks technique described on the attached link

    http://www.j-walk.com/ss/excel/usertips/tip040.htm

    I know I could use the code from Debra Dalgleish site but wanted to play with some VBA code myself and ask for some pointers

    http://www.contextures.com/xlDataEntry02.html#FillProg

    Here's what I've come up with so far. How would I trap the errors. Only using On error sesume next. Plus can I shorten the code

    Also can I adapt it to do more than one Column at a time


    Please Login or Register  to view this content.
    Thanks

    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
    Forum Expert Carim's Avatar
    Join Date
    04-07-2006
    Posts
    4,070
    Hi VBA Noob,

    Seems to me that replacing
    Please Login or Register  to view this content.
    with
    Please Login or Register  to view this content.
    would do the trick ... no ???

    Cheers
    Carim

  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
    Hi Carim,

    Cells.Select will select all the cells.

    Range(ActiveCell, Cells(Rows.Count, ActiveCell.Column).End(xlUp)).Select

    Selects the active cell down to the last cell in column with an entry.

    I was looking for tips on error trapping e.g No blank cells plus looking at ways to give the user the option to select more than one column.

    If that can't be done then maybe run on the first column and then at the end it pops up with an input box so the user can select the next column or press cancel if finshed.

    Could you set the user column selection and then loop through each row

    VBA Noob
    Last edited by VBA Noob; 11-19-2006 at 10:19 AM.

  4. #4
    Valued Forum Contributor
    Join Date
    06-16-2006
    Location
    Sydney, Australia
    MS-Off Ver
    2013 64bit
    Posts
    1,394
    Try using this as a replacement for your coloumn selection

    Please Login or Register  to view this content.
    To trap for the error, adding this line

    Please Login or Register  to view this content.
    Then add this line
    Please Login or Register  to view this content.
    x will be True if there are blanks and empty if there are not.

    Matt

  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
    Hi Matt,

    Thanks for the reply.

    I thought of the currentregion idea but there may be gaps in data.

    I think I will have to do it Column by Column

    VBA Noob

  6. #6
    Valued Forum Contributor
    Join Date
    06-16-2006
    Location
    Sydney, Australia
    MS-Off Ver
    2013 64bit
    Posts
    1,394
    How about this to select the region?

    Please Login or Register  to view this content.

  7. #7
    Forum Contributor
    Join Date
    03-13-2005
    Posts
    6,195
    Quote Originally Posted by VBA Noob
    Hi Matt,

    Thanks for the reply.

    I thought of the currentregion idea but there may be gaps in data.

    I think I will have to do it Column by Column

    VBA Noob
    Hi,

    Why not take the selected range, asin
    if a single cell is selected then the column from that point to column end (ie, last data),
    if a range of mutltiple rows and multiple columns is selected then those columns for those rows,
    and if a single row and multiple columns are selected then those columns from that row to each column end (last data).

    This avoids having to enter an annoying userbox range etc.

    hth
    ---
    Si fractum non sit, noli id reficere.

  8. #8
    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
    Hi Bryan,

    Selecting the range manually is the issue. If your blanks are bewteen A2:A10000 it's quicker to run it on each column then trying to find the last cell for each column

    VBA Noob

  9. #9
    Forum Contributor
    Join Date
    03-13-2005
    Posts
    6,195
    Quote Originally Posted by VBA Noob
    Hi Bryan,

    Selecting the range manually is the issue. If your blanks are bewteen A2:A10000 it's quicker to run it on each column then trying to find the last cell for each column

    VBA Noob
    Yes,

    hence the reason for the suggestion, the code can recognize three options,

    2, the unlikely 'Range' (ie A2:D500) and do the range,
    3, the possible multi-column (A2:D2) where it does columns A to D
    1, the probable single cell, (A2) where it does column A from 2 to the last data.

    For multi-column (or single column) you might decide the last data item for that column, or the last data in a range of columns.

    The last cell for each column can be from the 'xlUp' from that or from another column or columns.

    hth
    ---
    Last edited by Bryan Hessey; 11-20-2006 at 05:10 AM.

+ Reply to Thread

Thread Information

Users Browsing this Thread

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

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