Results 1 to 4 of 4

Thread: MACRO: How to import data from sheets.

Hybrid View

Previous Post Previous Post   Next Post Next Post
  1. #1
    Administrator Admin's Avatar
    Join Date
    Mar 2011
    Posts
    1,123
    Rep Power
    10
    Hi

    Try

    Code:
        Dim strDept As String
        Dim wksDest As Worksheet
        
        Set wksDest = Worksheets("Transfer to this sheet")  '<< adjust to suit
        
        strDept = Range("f16").Value2
        
        If Len(strDept) Then
            wksDest.UsedRange.Clear
            On Error GoTo 1
            Worksheets(CStr(strDept)).UsedRange.Copy wksDest.Range("a1")
        End If
        Exit Sub
    1:
        MsgBox "Worksheet '" & strDept & "' does not exist", vbCritical
    Cheers !

    Excel Range to BBCode Table
    Use Social Networking Tools If You Like the Answers !

    Message to Cross Posters

    @ Home - Office 2010/2013/2016 on Win 10 (64 bit); @ Work - Office 2016 on Win 10 (64 bit)

  2. #2
    Junior Member
    Join Date
    Jan 2013
    Posts
    19
    Rep Power
    0
    ah, it works perfect. Thank you very much

    Can you also please explain what dim, strDept, string and Len means?

    thanks again

    Cheers!

Similar Threads

  1. Macro To Browse Select File And Import Specific Data
    By violetpedal in forum Excel Help
    Replies: 4
    Last Post: 07-17-2013, 07:19 AM
  2. Replies: 3
    Last Post: 06-10-2013, 06:12 PM
  3. Replies: 7
    Last Post: 05-08-2013, 07:12 PM
  4. Macro To Clear Certain Data Across Many Sheets
    By Howardc in forum Excel Help
    Replies: 2
    Last Post: 12-04-2012, 09:10 AM
  5. Replies: 2
    Last Post: 11-08-2012, 01:15 PM

Posting Permissions

  • You may not post new threads
  • You may not post replies
  • You may not post attachments
  • You may not edit your posts
  •