+ Reply to Thread
Results 1 to 9 of 9

Define string in For Next loop

  1. #1
    Registered User
    Join Date
    06-15-2011
    Location
    Indianapolis, Indiana
    MS-Off Ver
    Excel 2007
    Posts
    14

    Define string in For Next loop

    I am trying to create a new worksheet in a separate workbook (Web Transfer Worksheet.xlt) for each instance of a unique cell D value and cell C value combination in the original workbook (strDate + "*_OmniTransferErrorReport.csv"). I imagine I will need to add an "If sheet already exists, skip to next" type of statement, but I am stuck on even getting it to work once. I am getting a type mismatch error on strNewSheetName = Cells(i, "D").Value + " " + Cells(i, "C").Value


    Any thoughts?

    Please Login or Register  to view this content.

  2. #2
    Forum Contributor arlu1201's Avatar
    Join Date
    09-09-2011
    Location
    Bangalore, India
    MS-Off Ver
    Excel 2003 & 2007
    Posts
    19,166

    Re: Define string in For Next loop

    Instead of "+", trying using the "&".

  3. #3
    Forum Contributor
    Join Date
    04-11-2011
    Location
    Columbus, Ohio
    MS-Off Ver
    Excel 2007
    Posts
    325

    Re: Define string in For Next loop

    Please Login or Register  to view this content.
    This won't solve your problem but will make things easier to work with possibly.
    I moved some stuff around. You will have to play around with it a little bit but I added the code to work with the other workbook easier.
    Last edited by 111StepsAhead; 11-17-2011 at 03:04 PM.

  4. #4
    Forum Moderator Leith Ross's Avatar
    Join Date
    01-15-2005
    Location
    San Francisco, Ca
    MS-Off Ver
    2000, 2003, & 2010
    Posts
    23,258

    Re: Define string in For Next loop

    Hello ,

    There are seven deadly characters that can not be used in workbook name.

    Illegal Characters in a Workbook Name
    ? / \ : [ ] *
    Sincerely,
    Leith Ross

    Remember To Do the Following....

    1. Use code tags. Place [CODE] before the first line of code and [/CODE] after the last line of code.
    2. Thank those who have helped you by clicking the Star below the post.
    3. Please mark your post [SOLVED] if it has been answered satisfactorily.


    Old Scottish Proverb...
    Luathaid gu deanamh maille! (Rushing causes delays!)

  5. #5
    Registered User
    Join Date
    06-15-2011
    Location
    Indianapolis, Indiana
    MS-Off Ver
    Excel 2007
    Posts
    14

    Re: Define string in For Next loop

    Quote Originally Posted by arlu1201 View Post
    Instead of "+", trying using the "&".
    Thanks arlu1202...

    I updated to this:

    Please Login or Register  to view this content.
    And that part works now.

    However, I am now getting caught on:

    Please Login or Register  to view this content.
    Leith, I wonder if you were referencing this statement. I am using * as a wildcard and it does work in a separate sub that I use to open that workbook:

    Please Login or Register  to view this content.
    Is the * in my activate code causing to error? If so, why would it work in the open statement?

  6. #6
    Registered User
    Join Date
    06-15-2011
    Location
    Indianapolis, Indiana
    MS-Off Ver
    Excel 2007
    Posts
    14

    Re: Define string in For Next loop

    Still need help please. Thanks!

  7. #7
    Registered User
    Join Date
    06-15-2011
    Location
    Indianapolis, Indiana
    MS-Off Ver
    Excel 2007
    Posts
    14

    Re: Define string in For Next loop

    I still need help on this one. Thanks!!

  8. #8
    Forum Contributor arlu1201's Avatar
    Join Date
    09-09-2011
    Location
    Bangalore, India
    MS-Off Ver
    Excel 2003 & 2007
    Posts
    19,166

    Re: Define string in For Next loop

    Will try something tomorrow if not will push it forward to the experts
    If I have helped, Don't forget to add to my reputation (click on the star below the post)
    Don't forget to mark threads as "Solved" (Thread Tools->Mark thread as Solved)
    Use code tags when posting your VBA code: [code] Your code here [/code]

  9. #9
    Forum Contributor arlu1201's Avatar
    Join Date
    09-09-2011
    Location
    Bangalore, India
    MS-Off Ver
    Excel 2003 & 2007
    Posts
    19,166

    Re: Define string in For Next loop

    However, I am now getting caught on:

    Please Login or Register  to view this content.
    Trying using the & again on the above line.
    Last edited by arlu1201; 12-01-2011 at 07:16 AM.

+ 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