+ Reply to Thread
Results 1 to 5 of 5

Please Help. Got Logic but dont quite understand how to Code it . Thanks :)

  1. #1
    Registered User
    Join Date
    10-11-2013
    Location
    Personal
    MS-Off Ver
    Excel 2010
    Posts
    13

    Please Help. Got Logic but dont quite understand how to Code it . Thanks :)

    Here what im trying to do (using excel vba)


    Please Login or Register  to view this content.
    /*all my work books are labeled WCSO#1(2013), WCSO#2(2013), WCSO#3,2013.....AND SO ON. (all in consecutive order) */

    1. i want to search for a closed workbook
    here's how the logic should perform the search:
    (a) look at the current workbook and "get the name of the current workbook".
    (b) using the "mid string function" MID( text, start_position, number_of_characters )
    search the string and retrieve indexes in the 6th, 7th and 8th position "only if they are numbers and follow each other"
    (and because do not want the numbers in the bracket to be counted in i.e.(2013).
    the numbers in WCSO sheet begin at index 6.

    (c) after the numbers are retrieved, place them in a string variable (for ex numString) then Convert them to an integer (numInt = CInt(numString))
    then add one to the integer numInt (i.e. numInt = numInt +1)
    then convert numInt back to a string (i.e. numStringNew= CStr(numInt) )

    (d) Use the replace function (Replace ( string1, find, replacement ) to find and replace the previous string in the current workbook name.
    I will copy the current workbook original string to a different variable.
    (e) now place that string variable in (what ever formula you use to reference a closed workbook and its sheet and cells withi)
    im not sure if this is ok but heres what ive got :

    Please Login or Register  to view this content.
    'i don't know how to open reference the sheet or the cells in range in the sheet
    ' i need to get the data (let says in cell A1:A50) and place it in my current workbook in the same range (i.e. Cells A1:A50)

    Please Login or Register  to view this content.
    Last edited by alansidman; 10-27-2013 at 12:37 PM. Reason: Code tags added

  2. #2
    Forum Moderator alansidman's Avatar
    Join Date
    02-02-2010
    Location
    Steamboat Springs, CO
    MS-Off Ver
    MS Office 365 insider Version 2504 Win 11
    Posts
    24,705

    Re: Please Help. Got Logic but dont quite understand how to Code it . Thanks :)

    Welcome to the forum

    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



    (I have added them for you this time. Please read all our rules and please abide by them in the future.)
    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
    Forum Expert mikerickson's Avatar
    Join Date
    03-30-2007
    Location
    Davis CA
    MS-Off Ver
    Excel 2011
    Posts
    6,229

    Re: Please Help. Got Logic but dont quite understand how to Code it . Thanks :)

    You might want to use this UDF. NextIndex("WCSO#1(2013)", "#") returns "WCSO#2(2013)"

    Please Login or Register  to view this content.
    Last edited by mikerickson; 10-27-2013 at 02:00 PM.
    _
    ...How to Cross-post politely...
    ..Wrap code by selecting the code and clicking the # or read this. Thank you.

  4. #4
    Registered User
    Join Date
    10-11-2013
    Location
    Personal
    MS-Off Ver
    Excel 2010
    Posts
    13

    Re: Please Help. Got Logic but dont quite understand how to Code it . Thanks :)

    ok heres what ive done: Almost completed
    pleas look at the code that has "Problem Here" written in it.

    it work fine once I explicitly state the name of the file that is located but I don't want to do that: I need to place the variable closedWorkbook in this spot
    Please Login or Register  to view this content.
    how can I fix this? ( I don't want to point to a specific file ...because I wont know what the file(workbook) is until it has been determined by the loop below.
    thanks.

    Please Login or Register  to view this content.

  5. #5
    Forum Expert mikerickson's Avatar
    Join Date
    03-30-2007
    Location
    Davis CA
    MS-Off Ver
    Excel 2011
    Posts
    6,229

    Re: Please Help. Got Logic but dont quite understand how to Code it . Thanks :)

    Rather than looping to get loopPosition, you could use
    Please Login or Register  to view this content.

+ 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] VBA Error i dont understand
    By Sparkplug90 in forum Excel Programming / VBA / Macros
    Replies: 1
    Last Post: 02-12-2013, 05:28 PM
  2. Please help me with this code ...i dont understand
    By umliu37 in forum Excel Programming / VBA / Macros
    Replies: 2
    Last Post: 07-06-2011, 02:02 AM
  3. I Dont understand how to create a prompt
    By smraines in forum Excel Programming / VBA / Macros
    Replies: 6
    Last Post: 12-14-2009, 03:27 AM
  4. Errors-I dont understand why
    By Buzzaro in forum Excel Programming / VBA / Macros
    Replies: 6
    Last Post: 08-28-2007, 11:59 PM
  5. Dont understand
    By realfolkblues in forum Excel General
    Replies: 1
    Last Post: 08-24-2006, 09:20 AM

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