+ Reply to Thread
Results 1 to 11 of 11

Trying to change a user input string

  1. #1
    Registered User
    Join Date
    06-16-2014
    Posts
    12

    Trying to change a user input string

    Hi,

    I have a macro that will take a list of data and sort it, on a new sheet, based on a template that I have created.

    I am trying to automate the process a little more and need some help.

    From this bit of code:
    Please Login or Register  to view this content.
    The user gives the sheet where the list of information is lets call this sheet 'list'.

    It then copies the sheet 'master' and renames it before moving the data.

    I would like to automatically rename the 'master' sheet to 'listm'. [whatever the user inputs + m on the end]

    I have tried the bold above and multiple variations to no avail.

    Could anyone give me any pointers?

    Many thanks in advance,
    Last edited by Leith Ross; 06-19-2014 at 10:48 AM. Reason: Added Code Tags

  2. #2
    Forum Expert
    Join Date
    11-29-2010
    Location
    Ukraine
    MS-Off Ver
    Excel 2019
    Posts
    4,168

    Re: Trying to change a user input string

    hi mrpwebb, welcome to Excelforum.

    You need to use special code tags while posting any VB coding at the fourm as per the Forum Rules #3: http://www.excelforum.com/forum-rule...rum-rules.html

    If to not get into the logic of your actions, it could be done this way (one of the options), press "Start" button
    Attached Files Attached Files

  3. #3
    Registered User
    Join Date
    06-16-2014
    Posts
    12

    Re: Trying to change a user input string

    Sorry for the wrong formatting last time.

    I will try again here.

    The above code is causing a run time error '424' object required to appear

    The reason behind wanting to get this to happen is that I am lazy and instead of starting 3/4 different macros and entering the same information with minor differences (which are the same for each sheet) I would like it to be automated.

    I have included the whole code for this macro below. [hopefully correctly inserted]

    Please Login or Register  to view this content.
    Once again thank you for any and all help

  4. #4
    Forum Expert
    Join Date
    11-29-2010
    Location
    Ukraine
    MS-Off Ver
    Excel 2019
    Posts
    4,168

    Re: Trying to change a user input string

    hi there,

    1. The code posted correctly in post #3, thanks. The code in post #1 is still missing correct format for code posted.

    2. The code from #1 has error:
    Please Login or Register  to view this content.
    Set is used to create an object not a variable to hold string value in your case

    3. The code posted in reply #3 is not the same with the posted code in #1. The code is OK in terms of running it from the start to the end.

    Can you explain what exactly do you want help with?

  5. #5
    Registered User
    Join Date
    06-16-2014
    Posts
    12

    Re: Trying to change a user input string

    Hi,

    The code in #3 works.

    I would like to change it so that instead of asking for another user input for the new 'master' sheet name it takes the init value and adds an 'm' at the end and uses that value as the new name

  6. #6
    Forum Expert
    Join Date
    11-29-2010
    Location
    Ukraine
    MS-Off Ver
    Excel 2019
    Posts
    4,168

    Re: Trying to change a user input string

    things to consider if user enters sheet name to use:
    1. Sheet name length should be no more than 31 symbols
    2. The following signs are not allowed in the sheet name: : \ / ? * [ ]
    3. Sheet name can not be null string
    4. New sheet name is already existing

    For now it's not accounted for as I do not know what should be done in this case within your code logic events.

    Please Login or Register  to view this content.

  7. #7
    Registered User
    Join Date
    06-16-2014
    Posts
    12

    Re: Trying to change a user input string

    This code runs fine [no errors appear], however a new sheet is created which is called 'master (2)' and the data is not transferred.

  8. #8
    Forum Expert
    Join Date
    11-29-2010
    Location
    Ukraine
    MS-Off Ver
    Excel 2019
    Posts
    4,168

    Re: Trying to change a user input string

    hi there,

    You get Master (2) sheet only in the case if a sheet with the same name exists.

    Except for this code extract that has no logic:

    Please Login or Register  to view this content.
    I do not see any other reason for trouble. If the values are equal what is the point to check which of them is higher. Obviously none.

    The sheet is created and named as per your request and data is transferred accordingly. Please check attachment with your code and amendment from post #6. Press Run button
    Attached Files Attached Files

  9. #9
    Registered User
    Join Date
    06-16-2014
    Posts
    12

    Re: Trying to change a user input string

    This now works.

    There was a hidden sheet of the same name. (My fault)

    The check "C" was also an error. The second check was meant to be "K" a date and delete the older entry.

    Thank you for all your help.

  10. #10
    Forum Expert
    Join Date
    11-29-2010
    Location
    Ukraine
    MS-Off Ver
    Excel 2019
    Posts
    4,168

    Re: Trying to change a user input string

    Hi there. Are we done with it?

  11. #11
    Registered User
    Join Date
    06-16-2014
    Posts
    12

    Re: Trying to change a user input string

    Yes. Thank you again.

+ 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 determine if the user input a STRING or an INTEGER?
    By mcmunoz in forum Excel Programming / VBA / Macros
    Replies: 6
    Last Post: 08-26-2013, 10:32 PM
  2. user defined macro to replace certain characters in a string based on user input
    By whatappears in forum Excel Programming / VBA / Macros
    Replies: 2
    Last Post: 12-17-2012, 06:25 PM
  3. User Input to change cell reference in formulas
    By williampdx in forum Excel General
    Replies: 5
    Last Post: 03-31-2010, 02:04 PM
  4. Auto Generation of String based on user input
    By dhimbak in forum Excel General
    Replies: 3
    Last Post: 06-04-2009, 09:12 AM
  5. [SOLVED] Change color of cell after user has input a number
    By F7772 in forum Excel General
    Replies: 3
    Last Post: 08-29-2005, 05:05 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