+ Reply to Thread
Results 1 to 12 of 12

Cell offset based on number of cells in selection

  1. #1
    Registered User
    Join Date
    08-10-2012
    Location
    NY
    MS-Off Ver
    Excel 2010
    Posts
    78

    Cell offset based on number of cells in selection

    Hi Guys--

    I am working on a macro and this section has me stumped. The worksheet columns are A:AE. Occasionally, the procedure needs to select a varying number of cells in a row which don't always fall in the same column, count the number of cells in the selection and then paste the data on the row above it, in column ("AE" minus the Selection Count).

    Here is what I have so far:

    Please Login or Register  to view this content.
    The red-bold bracketed code is the syntax I'm not able to figure out how to phrase.

    Can anyone help?

    Thanks
    Jerry

  2. #2
    Forum Contributor
    Join Date
    06-22-2011
    Location
    somerset
    MS-Off Ver
    365
    Posts
    328

    Re: Cell offset based on number of cells in selection

    AE needs to be a number. 31

    Edit: or you can do range("AE:AE").column
    Sub Reputation()
    Dim Problem as Variant
    Dim Reputation as Integer
    For Each Problem in Forum.Threads
        If Problem.Title = "*[Solved]*" and Solver.Name = "Leon V (AW)" Then Reputation = Reputation + 1
    Next Problem
    End Sub

  3. #3
    Registered User
    Join Date
    08-10-2012
    Location
    NY
    MS-Off Ver
    Excel 2010
    Posts
    78

    Re: Cell offset based on number of cells in selection

    Would you please show me the syntax? When I use

    Please Login or Register  to view this content.
    or
    Please Login or Register  to view this content.
    It pastes into column AF (which makes no sense to me at all).

  4. #4
    Registered User
    Join Date
    08-10-2012
    Location
    NY
    MS-Off Ver
    Excel 2010
    Posts
    78

    Re: Cell offset based on number of cells in selection

    Can anybody help me please?

  5. #5
    Forum Contributor
    Join Date
    06-22-2011
    Location
    somerset
    MS-Off Ver
    365
    Posts
    328

    Re: Cell offset based on number of cells in selection

    your code should select 1 row up on column 61 and paste.

    Is this what you are trying to do?
    Please Login or Register  to view this content.
    Last edited by Leon V (AW); 04-16-2014 at 12:11 PM.

  6. #6
    Registered User
    Join Date
    08-10-2012
    Location
    NY
    MS-Off Ver
    Excel 2010
    Posts
    78

    Re: Cell offset based on number of cells in selection

    Leon - thanks. The code works when I manually select and cut cells and then run it
    but when I preceed it with
    Please Login or Register  to view this content.
    it only pastes the first cell's contents into the last column of the prior row.

  7. #7
    Forum Contributor
    Join Date
    06-22-2011
    Location
    somerset
    MS-Off Ver
    365
    Posts
    328

    Re: Cell offset based on number of cells in selection

    what are you trying to achieve with this line?
    Please Login or Register  to view this content.

  8. #8
    Registered User
    Join Date
    08-10-2012
    Location
    NY
    MS-Off Ver
    Excel 2010
    Posts
    78

    Re: Cell offset based on number of cells in selection

    Select and cut all data in a row, where
    • the number of cells to be selected varies
    • there are blank cells within the desired selection, and
    • the first and last column letter is not always the same

  9. #9
    Forum Guru
    Join Date
    03-02-2006
    Location
    Los Angeles, Ca
    MS-Off Ver
    WinXP/MSO2007;Win10/MSO2016
    Posts
    12,613

    Re: Cell offset based on number of cells in selection

    To attach a Workbook
    (please do not post pictures of worksheets)
    • Click Advanced (next to quick post),
    • Scroll down until you see "Manage Attachments",
    • Click that then select "add files" (top right corner).
    • Click "Select Files" find your file, click "open" click "upload"
    • Once the upload is completed the file name will appear below the input boxes in this window.
    • Click "Done" at bottom right to close the Attachment Manager.
    • Click "Submit Reply"
    Ben Van Johnson

  10. #10
    Forum Contributor
    Join Date
    06-22-2011
    Location
    somerset
    MS-Off Ver
    365
    Posts
    328

    Re: Cell offset based on number of cells in selection

    so something like this?
    Please Login or Register  to view this content.

  11. #11
    Registered User
    Join Date
    08-10-2012
    Location
    NY
    MS-Off Ver
    Excel 2010
    Posts
    78

    Re: Cell offset based on number of cells in selection

    Quote Originally Posted by protonLeah View Post
    To attach a Workbook
    (please do not post pictures of worksheets)
    • Click Advanced (next to quick post),
    • Scroll down until you see "Manage Attachments",
    • Click that then select "add files" (top right corner).
    • Click "Select Files" find your file, click "open" click "upload"
    • Once the upload is completed the file name will appear below the input boxes in this window.
    • Click "Done" at bottom right to close the Attachment Manager.
    • Click "Submit Reply"
    I'm not sure what you're talking about protonLeah. I didn't attach or post pictures of anything. If I had, I'm quite aware of how to do so.

  12. #12
    Registered User
    Join Date
    08-10-2012
    Location
    NY
    MS-Off Ver
    Excel 2010
    Posts
    78

    Re: Cell offset based on number of cells in selection

    Leon, that's the exact code you posted originally except for the "clear contents" part
    I made it work though by modifying the method I use to select the data.

    Thanks for your help man!

+ 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. Pasting Cells Using an Offset Command based on Variable Cell Data
    By SysEng in forum Excel - New Users/Basics
    Replies: 5
    Last Post: 03-03-2014, 10:42 AM
  2. Clear cell contents based on offset of dropdown selection on another tab.
    By Drivium in forum Excel Programming / VBA / Macros
    Replies: 1
    Last Post: 03-22-2013, 10:58 PM
  3. Replies: 3
    Last Post: 01-31-2013, 09:38 PM
  4. Searching for an Offset Value based on Combo Box Selection
    By CaddyMatt in forum Excel Formulas & Functions
    Replies: 2
    Last Post: 09-05-2012, 01:33 PM
  5. [SOLVED] Disable Cells based on Cell Selection
    By HangMan in forum Excel Programming / VBA / Macros
    Replies: 14
    Last Post: 07-03-2012, 12:21 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