+ Reply to Thread
Results 1 to 3 of 3

VBA - Select cells right that have formatting

  1. #1
    Forum Contributor
    Join Date
    11-17-2004
    MS-Off Ver
    Office 2016
    Posts
    527

    VBA - Select cells right that have formatting

    The following line of code is in a Sub that copies a formula across to the right. It works fine when there's already something in those cells but if I use this selection and there's nothing in the cells to the right it'll copy across every possible cell in the worksheet. To prevent this I enter a character in the last column I'm working on but I'm wondering if there's an option for the select statement that will select to the right up to the last cell that has some sort of formatting instead of data.

    This way I can draw borders around the area I'm working on and select/copy right up to the last cell with formatting instead of accidentally entering data in every last cell to the right on the worksheet filling it with thousands of data points and formulas unnecessarily. I use this particular macro a lot in my work and it can stop my computer for a long periods of time if I do this with a whole column of formulas to copy across.

    Bottom line, what I'd like to do is select to the right only cells that have some form of formatting.

    This is the line used now.
    Please Login or Register  to view this content.

  2. #2
    Forum Guru MarvinP's Avatar
    Join Date
    07-23-2010
    Location
    Woodinville, WA
    MS-Off Ver
    Office 365
    Posts
    16,169

    Re: VBA - Select cells right that have formatting

    Hi JimDandy,

    I think you are looking for some function dealing with "UsedRange"

    Try to incorporate Application.ActiveSheet.Usedrange.Column into a formula. UsedRange will give the address of the last row and last column used on a sheet.
    One test is worth a thousand opinions.
    Click the * Add Reputation below to say thanks.

  3. #3
    Forum Contributor
    Join Date
    11-17-2004
    MS-Off Ver
    Office 2016
    Posts
    527

    Re: VBA - Select cells right that have formatting

    Thanks, I can see some success with that but I'll need to do some more trial and error to get it right.

+ 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. [SOLVED] How to select 3 cells, transpose, loop to select next 3 cells.
    By Hood in forum Excel Programming / VBA / Macros
    Replies: 2
    Last Post: 03-02-2017, 02:07 PM
  2. Formatting cells other than select-highlighting the cells to apply the format?
    By Joe Miller in forum Excel Formulas & Functions
    Replies: 6
    Last Post: 09-27-2014, 10:53 AM
  3. Conditional formatting - select all cells showing.....
    By Nickyh1984 in forum Excel Programming / VBA / Macros
    Replies: 0
    Last Post: 06-10-2014, 04:42 AM
  4. Replies: 3
    Last Post: 07-18-2012, 07:25 AM
  5. Excel 2007 : Conditional Formatting - Select Data
    By Uzzgee in forum Excel General
    Replies: 1
    Last Post: 11-15-2011, 10:31 AM
  6. Replies: 5
    Last Post: 10-31-2005, 11:05 AM
  7. can not select conditional formatting
    By gbeard in forum Excel Formulas & Functions
    Replies: 2
    Last Post: 04-10-2005, 03: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