+ Reply to Thread
Results 1 to 6 of 6

Select case logical range copy/paste routine

  1. #1
    Registered User
    Join Date
    04-22-2011
    Location
    London
    MS-Off Ver
    Excel 2003
    Posts
    59

    Select case logical range copy/paste routine

    I am trying to find the shortest method for users to import their downloaded .csv bank statements into a personal finance workbook.

    The column order depending on which bank is involved will differ (and there will be more than needed) so I thought about using a staging sheet to paste into so the user can name the required columns before pasting into the destination sheet.

    I have 5 columns in the final destination sheet:

    Date, Type, Description, Amount, Running Balance

    I have created 10 dynamic named ranges in the staging sheet to accept the raw imported data. (these dynamic ranges are named IMPORTCOL1, IMPORTCOL2 etc..) I have also added data validation drop downs on the head of each import column containing a list of my 5 columns headers in the destination sheet.

    What I am trying to do is have code determine which of the 5 needed destination columns the imported column data should be sent to. I know there must be code to loop through each of the 5 required imported columns with values entered in the drop down by the user but for now I would be more than happy to have them execute each column copy/paste routine by a form control button sitting above each import column.

    I need to modify this basic code to have it look for the value in the drop down in for example column A (assumes column A is 1 of the 5 to be copied/pasted) and then decide which of the 5 columns in the destination sheet it needs to go to. I suspect this is a Select Case job but I'm unsure how to structure the Case statement? It's been a good while since I've tinkered with any VBA and sadly I've forgotten most of what little I knew. That said if I could get some initial help with this I hope some memory will return


    Please Login or Register  to view this content.
    Many thanks
    Last edited by coasterman; 09-22-2013 at 06:43 AM.

  2. #2
    Forum Guru Norie's Avatar
    Join Date
    02-02-2005
    Location
    Stirling, Scotland
    MS-Off Ver
    Microsoft Office 365
    Posts
    19,643
    I don't quite see how a Select Case would be used/needed here.

    Why not put the 5 headers you want to copy from the import into an array?

    Then you could loop through the array and use code, eg Application.Match, to find each header in the header row of the imported data.

    When you find a header copy the column from the imported data to the appropriate column in the destination sheet.
    If posting code please use code tags, see here.

  3. #3
    Registered User
    Join Date
    04-22-2011
    Location
    London
    MS-Off Ver
    Excel 2003
    Posts
    59

    Re: Select case logical range copy/paste routine

    Thanks for the reply, I've been reading up since the post and am no clearer. I've never used arrays in VBA before so the whilst I have some understanding of them within worksheet formulas I'm at a complete loss in code. I couldn't even find how to manually declare the static array.

    I need to narrow my questions as I have many but to focus in on what's needed I think I need a little help to get me started on the code if you have the time.

  4. #4
    Forum Guru Norie's Avatar
    Join Date
    02-02-2005
    Location
    Stirling, Scotland
    MS-Off Ver
    Microsoft Office 365
    Posts
    19,643

    Re: Select case logical range copy/paste routine

    Can you upload a sample workbook with the imported data on one sheet and a blank, except headers, destination sheet?

  5. #5
    Registered User
    Join Date
    04-22-2011
    Location
    London
    MS-Off Ver
    Excel 2003
    Posts
    59

    Re: Select case logical range copy/paste routine

    Thanks one again for looking.

    Hi, I've pared down to what I hope is the minimum needed and recreated the dynamic ranges.

    I didn't add the buttons on the import sheet as I think you were suggesting there is a more elegant way than multiple user button presses using an array?
    Attached Files Attached Files

  6. #6
    Registered User
    Join Date
    04-22-2011
    Location
    London
    MS-Off Ver
    Excel 2003
    Posts
    59

    Re: Select case logical range copy/paste routine

    Forgive me for the small bump but this board just fills up so quickly I suspect my response from Monday has disappeared off the radar.

+ 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. Excel VBA - Problem programming routine for conditional copy/paste
    By CydMM in forum Excel Programming / VBA / Macros
    Replies: 4
    Last Post: 01-31-2012, 07:50 AM
  2. Find Text, Select range below, copy, paste to new work sheet
    By kim5012 in forum Excel Programming / VBA / Macros
    Replies: 2
    Last Post: 04-13-2011, 07:10 PM
  3. Select Range, Copy, Paste, FAIL! :p
    By prefix in forum Excel Programming / VBA / Macros
    Replies: 5
    Last Post: 09-08-2009, 03:46 AM
  4. Variable to select range to copy and paste to
    By cecil23 in forum Excel Programming / VBA / Macros
    Replies: 7
    Last Post: 07-30-2007, 02:35 AM
  5. help w/ generic copy & paste/paste special routine
    By DavidH in forum Excel Programming / VBA / Macros
    Replies: 5
    Last Post: 01-23-2006, 12:00 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