+ Reply to Thread
Results 1 to 14 of 14

VBA: format newly created sheets as text

  1. #1
    Registered User
    Join Date
    09-26-2012
    Location
    London, England
    MS-Off Ver
    Excel 2007
    Posts
    80

    VBA: format newly created sheets as text

    I have a macro named checkURL which creates multiple sheets. The code is below.
    I want to add some code so that as soon as sheets are created - it will format the created sheet as text and performs the required of the actions.

    Please Login or Register  to view this content.

  2. #2
    Valued Forum Contributor tehneXus's Avatar
    Join Date
    04-12-2013
    Location
    Hamburg, Germany
    MS-Off Ver
    Work: MS-Office 2010 32bit @ Win8 32bit / Home: MS-Office 2016 32bit @ Win10 64bit
    Posts
    944

    Re: VBA: format newly created sheets as text

    try
    Please Login or Register  to view this content.
    Please use [CODE]-TAGS
    When your problem is solved mark the thread SOLVED
    If an answer has helped you please click to give reputation
    Read the FORUM RULES

  3. #3
    Registered User
    Join Date
    09-26-2012
    Location
    London, England
    MS-Off Ver
    Excel 2007
    Posts
    80

    Re: VBA: format newly created sheets as text

    This line is giving problem:My links are in sheet named weblink page.
    Set MyRange = Sheet1.Range("A1:A" & Sheet1.Range("A" & Rows.Count).End(xlUp).Row)

    If I runs the macro 2nd time it shows sheet1 is not available.
    Last edited by maria.blue44; 05-20-2013 at 08:51 AM.

  4. #4
    Registered User
    Join Date
    09-26-2012
    Location
    London, England
    MS-Off Ver
    Excel 2007
    Posts
    80

    Re: VBA: format newly created sheets as text

    Seems if is missing as well.

  5. #5
    Registered User
    Join Date
    09-26-2012
    Location
    London, England
    MS-Off Ver
    Excel 2007
    Posts
    80

    Re: VBA: format newly created sheets as text

    Still looking for a working solution !!!

  6. #6
    Valued Forum Contributor tehneXus's Avatar
    Join Date
    04-12-2013
    Location
    Hamburg, Germany
    MS-Off Ver
    Work: MS-Office 2010 32bit @ Win8 32bit / Home: MS-Office 2016 32bit @ Win10 64bit
    Posts
    944

    Re: VBA: format newly created sheets as text

    Hi,

    if your data is in "weblink page" you should be very sure that this sheet will never be removed because you are using the codename in:
    Please Login or Register  to view this content.
    try
    Please Login or Register  to view this content.
    If this does not help it would be great to see a sample workbook

  7. #7
    Registered User
    Join Date
    09-26-2012
    Location
    London, England
    MS-Off Ver
    Excel 2007
    Posts
    80

    Re: VBA: format newly created sheets as text

    Please find the attachment.
    Attached Files Attached Files

  8. #8
    Valued Forum Contributor tehneXus's Avatar
    Join Date
    04-12-2013
    Location
    Hamburg, Germany
    MS-Off Ver
    Work: MS-Office 2010 32bit @ Win8 32bit / Home: MS-Office 2016 32bit @ Win10 64bit
    Posts
    944

    Re: VBA: format newly created sheets as text

    Hi, please check the file attached: Bookm.xlsm

    I made some testing with financial data from yahoo and changed the following line, which, I think was your problem. Unfortunately the dates where created although the number-format was set to Text...
    Please Login or Register  to view this content.
    (Note: The URL list must be in "weblink page", if not you have to change it in the code or, rewrite code to ActiveSheet or sth.)

  9. #9
    Registered User
    Join Date
    09-26-2012
    Location
    London, England
    MS-Off Ver
    Excel 2007
    Posts
    80

    Re: VBA: format newly created sheets as text

    In my page I have a value "9E10" which turns into "9.00E+10". For such cases only I want to turn my newly created sheets as text.

  10. #10
    Registered User
    Join Date
    09-26-2012
    Location
    London, England
    MS-Off Ver
    Excel 2007
    Posts
    80

    Re: VBA: format newly created sheets as text

    So the solution did not work on my data. i.e .WebDisableDateRecognition = True

  11. #11
    Valued Forum Contributor tehneXus's Avatar
    Join Date
    04-12-2013
    Location
    Hamburg, Germany
    MS-Off Ver
    Work: MS-Office 2010 32bit @ Win8 32bit / Home: MS-Office 2016 32bit @ Win10 64bit
    Posts
    944

    Re: VBA: format newly created sheets as text

    Could you provide a URL where "9E10" is in the table?

  12. #12
    Registered User
    Join Date
    09-26-2012
    Location
    London, England
    MS-Off Ver
    Excel 2007
    Posts
    80

    Re: VBA: format newly created sheets as text

    I can not disclose the link. I thought to send you a message in your inbox but I am not allowed perhaps because of making duplicate post.

  13. #13
    Valued Forum Contributor tehneXus's Avatar
    Join Date
    04-12-2013
    Location
    Hamburg, Germany
    MS-Off Ver
    Work: MS-Office 2010 32bit @ Win8 32bit / Home: MS-Office 2016 32bit @ Win10 64bit
    Posts
    944

    Re: VBA: format newly created sheets as text

    Hello,

    So I found out that excel is guessing the format of the text its importing and then setting the format to whatever it wants, I did not found any property in the QueryTable object to prevent this.
    Setting the NumberFormat to text either before or after the import does not change this.
    The only thing I could image right now is a workaround, looping all imported cells, checking for a format which is not text and then changing the value with some string operations.

    Sorry for not having a better idea

  14. #14
    Registered User
    Join Date
    09-26-2012
    Location
    London, England
    MS-Off Ver
    Excel 2007
    Posts
    80

    Re: VBA: format newly created sheets as text

    I think its the only best idea

+ Reply to Thread

Thread Information

Users Browsing this Thread

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

Tags for this Thread

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