+ Reply to Thread
Results 1 to 2 of 2

Finding next empty empty cell in a range of columns

  1. #1
    UncleBun
    Guest

    Finding next empty empty cell in a range of columns

    I have been through the posts here and can not find exactly the same senario
    as I want to perform.

    I have a spreadsheet where data will be held in columns for people. Each
    person has its own column. I want to be able to place a persons name in the
    heading of each column. So I am trying to find the next empty column in row 3
    to place the name.

    The code I have used but does not appear to work is

    NextCol = Application.WorksheetFunction.CountA(Range("D3:W3")) + 1

    It always returns a value of 1.

    This code is in a commandButton(Click) proceedure. I thought it would look
    at the range and give me the next column free as a response?




  2. #2
    Dave Peterson
    Guest

    Re: Finding next empty empty cell in a range of columns

    maybe...

    Dim NextCol as long

    with activesheet
    nextcol = .cells(3,.columns.count).end(xltoleft).column + 1
    end with

    But the only way I would think your code wouldn't work is if the code was
    looking at the wrong sheet:

    NextCol _
    = Application.WorksheetFunction.CountA(worksheets("Sheet99").Range("D3:W3")) + 1

    UncleBun wrote:
    >
    > I have been through the posts here and can not find exactly the same senario
    > as I want to perform.
    >
    > I have a spreadsheet where data will be held in columns for people. Each
    > person has its own column. I want to be able to place a persons name in the
    > heading of each column. So I am trying to find the next empty column in row 3
    > to place the name.
    >
    > The code I have used but does not appear to work is
    >
    > NextCol = Application.WorksheetFunction.CountA(Range("D3:W3")) + 1
    >
    > It always returns a value of 1.
    >
    > This code is in a commandButton(Click) proceedure. I thought it would look
    > at the range and give me the next column free as a response?


    --

    Dave Peterson

+ 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