Closed Thread
Results 1 to 10 of 10

need variable for range instead of cell

  1. #1
    Registered User
    Join Date
    10-29-2015
    Location
    Lake Mills, Iowa
    MS-Off Ver
    2013
    Posts
    30

    need variable for range instead of cell

    I have a userform with, at this time 93 textboxes, checkboxes, and option buttons. I have coded the values from these objects to a worksheet named inputs.

    Inputs.Range("C4").Value = txName.Value

    I need to change C4 to a variable so that each time I save my form it moves one column over. I want to start at C4, save my values, move to D4, save my values, etc.
    This is what I have:
    [code]
    Dim opencell As String
    Inputs.Activate
    Inputs.Range("C4").Activate
    Do Until IsEmpty(ActiveCell.Value)
    ActiveCell.Offset(0, 1).Select
    Loop
    opencell = ActiveCell.Address

    Inputs.Range("opencell ").Value = txName.Value
    [code]
    And I get run time error 1004
    Method ‘Range of object’_Worksheet’ failed
    Any help would be appreciated.
    Thank you

  2. #2
    Forum Moderator alansidman's Avatar
    Join Date
    02-02-2010
    Location
    Steamboat Springs, CO
    MS-Off Ver
    MS Office 365 Version 2405 Win 11 Home 64 Bit
    Posts
    23,930

    Re: need variable for range instead of cell

    Your post does not comply with Rule 3 of our Forum RULES. Use code tags around code.

    Posting code between [CODE]Please [url=https://www.excelforum.com/login.php]Login or Register [/url] to view this content.[/CODE] tags makes your code much easier to read and copy for testing, it also maintains VBA formatting.

    Highlight your code and click the # icon at the top of your post window. More information about these and other tags can be found here



    (This thread should receive no further responses until this moderation request is fulfilled, as per Forum Rule 7)
    Alan עַם יִשְׂרָאֵל חַי


    Change an Ugly Report with Power Query
    Database Normalization
    Complete Guide to Power Query
    Man's Mind Stretched to New Dimensions Never Returns to Its Original Form

  3. #3
    Registered User
    Join Date
    10-29-2015
    Location
    Lake Mills, Iowa
    MS-Off Ver
    2013
    Posts
    30

    Re: need variable for range instead of cell

    there is no # icon at the top of my post window

  4. #4
    Registered User
    Join Date
    10-29-2015
    Location
    Lake Mills, Iowa
    MS-Off Ver
    2013
    Posts
    30

    Re: need variable for range instead of cell

    also I get a web attack nuclear exploit kit form Norton

  5. #5
    Forum Moderator alansidman's Avatar
    Join Date
    02-02-2010
    Location
    Steamboat Springs, CO
    MS-Off Ver
    MS Office 365 Version 2405 Win 11 Home 64 Bit
    Posts
    23,930

    Re: need variable for range instead of cell

    Please see the pictureCapture.PNG
    This is while you are in the edit/response mode.
    Last edited by alansidman; 02-13-2016 at 11:19 PM.

  6. #6
    Registered User
    Join Date
    10-29-2015
    Location
    Lake Mills, Iowa
    MS-Off Ver
    2013
    Posts
    30

    Re: need variable for range instead of cell

    well Sir I must be doing something I RMB click and then LMB click the show picture and nothing happens

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

    Re: need variable for range instead of cell

    DonaldT

    Edit you first post and add / to 2nd [noparse][code]Please [url=https://www.excelforum.com/login.php]Login or Register [/url] to view this content.[/code]

  8. #8
    Registered User
    Join Date
    10-29-2015
    Location
    Lake Mills, Iowa
    MS-Off Ver
    2013
    Posts
    30

    Re: need variable for range instead of cell

    thanks I will try that
    as far as edit my post, I click on the edit button and the entire post is erased. I use the back arrow to get out of the edit and it returns as is.
    I tried to copy the entire post and paste it back, then edit and save , still blank.
    I'm not very good at this it would seem

  9. #9
    Registered User
    Join Date
    10-29-2015
    Location
    Lake Mills, Iowa
    MS-Off Ver
    2013
    Posts
    30

    Re: need variable for range instead of cell

    that worked thank you. how can I use cell offset and move 1 row down

    Please Login or Register  to view this content.

  10. #10
    Forum Moderator alansidman's Avatar
    Join Date
    02-02-2010
    Location
    Steamboat Springs, CO
    MS-Off Ver
    MS Office 365 Version 2405 Win 11 Home 64 Bit
    Posts
    23,930

    Re: need variable for range instead of cell

    Since this thread has gone on without you being able to edit the post, I will close this. Please start a new post and do use code tags when you do.

Closed Thread

Thread Information

Users Browsing this Thread

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

Similar Threads

  1. [SOLVED] Set range address as variable and then clear the cell via the variable
    By kosherboy in forum Excel Programming / VBA / Macros
    Replies: 3
    Last Post: 01-13-2016, 02:23 PM
  2. [SOLVED] Use cell variable in Range
    By rizmomin in forum Excel Programming / VBA / Macros
    Replies: 3
    Last Post: 07-26-2014, 03:21 PM
  3. [SOLVED] Possible to control cell range with another cell as a variable - then use Solver?
    By hadamhiram in forum Excel Formulas & Functions
    Replies: 5
    Last Post: 12-17-2013, 02:25 AM
  4. [SOLVED] Copy/Paste Values from Variable Range to Corresponding Variable Range
    By Cpetersoc in forum Excel Programming / VBA / Macros
    Replies: 9
    Last Post: 05-14-2012, 08:20 AM
  5. [SOLVED] Using cell value to define a range (for a variable defined as a range)
    By Sccye in forum Excel Programming / VBA / Macros
    Replies: 10
    Last Post: 04-02-2012, 10:25 AM
  6. VBA Variable Cell Range
    By Barrie in forum Excel General
    Replies: 1
    Last Post: 02-02-2011, 08:22 AM
  7. Variable Cell Range
    By agnewt in forum Excel Formulas & Functions
    Replies: 1
    Last Post: 10-01-2008, 03:19 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