+ Reply to Thread
Results 1 to 5 of 5

Excel 2007 : How to create a button and automate the process of transferring data?

  1. #1
    Registered User
    Join Date
    05-27-2009
    Location
    USA
    MS-Off Ver
    Excel 2007
    Posts
    22

    How to create a button and automate the process of transferring data?

    Hi Everyone,

    I have a code which loads data from source workbook to destination workbook, but inorder to do it , I need to open both the work books,I have to press Alt+F11, paste the code in the VBA editior and run.
    Is there any simpler way make this happen by creating a button on the destination work book? so that just at the click of the button everything happens automatically.

    ThanQ

    djkahc

  2. #2
    Forum Expert JBeaucaire's Avatar
    Join Date
    03-21-2004
    Location
    Bakersfield, CA
    MS-Off Ver
    2010, 2016, Office 365
    Posts
    33,492

    Re: How to create a button and automate the process of transferring data?

    Yes.

    Go ahead and insert the code into your destination workbook, then here in the forum click on GO ADVANCED and use the paperclip icon to upload the workbook.

    Then give us the name, and the full path to the file you're pulling data in from. Go ahead and upload a sample of that sheet, too, if you wish.

    That should be enough for someone to quickly turn your macro into a BUTTON that also opens the file when clicked.
    _________________
    Microsoft MVP 2010 - Excel
    Visit: Jerry Beaucaire's Excel Files & Macros

    If you've been given good help, use the icon below to give reputation feedback, it is appreciated.
    Always put your code between code tags. [CODE] your code here [/CODE]

    ?None of us is as good as all of us? - Ray Kroc
    ?Actually, I *am* a rocket scientist.? - JB (little ones count!)

  3. #3
    Registered User
    Join Date
    05-27-2009
    Location
    USA
    MS-Off Ver
    Excel 2007
    Posts
    22

    Re: How to create a button and automate the process of transferring data?

    can u provide m with the procedure so that I can do it my self?

  4. #4
    Registered User
    Join Date
    05-27-2009
    Location
    USA
    MS-Off Ver
    Excel 2007
    Posts
    22

    Re: How to create a button and automate the process of transferring data?

    Sub moveData()
    Dim i As Long, j As Long, flag As Boolean
    Dim MyCols(1 To 5) As String
    Dim k As Long
    Dim counter As Long
    Dim label1 As String



    MyCols(1) = "B"
    MyCols(2) = "C"
    MyCols(3) = "D"
    MyCols(4) = "E"

    counter = 0
    k = 1
    vertical_count = 0

    j = Workbooks("Destination0.xlsx").Sheets("Sheet1").Range("B25").Row + 1

    flag = False

    For i = 1 To Workbooks("consolidated.csv").Sheets("consolidated").Range("G65536").End(xlUp).Row Step 1


    If Workbooks("consolidated.csv").Sheets("consolidated").Range("G" & i).Value = "IOps" Then
    flag = True

    End If

    If Workbooks("consolidated.csv").Sheets("consolidated").Range("G" & i).Value <> "IOps" And flag = True Then
    flag = False
    Workbooks("Destination0.xlsx").Sheets("Sheet1").Range(MyCols(k) & j).Value = _
    Workbooks("consolidated.csv").Sheets("consolidated").Range("G" & i).Value
    counter = counter + 1

    If counter = 5 Or counter = 10 Or counter = 15 Or counter = 20 Then
    j = j - 4
    k = k + 1
    Else
    j = j + 1
    End If

    If counter = 20 Then
    k = 1
    counter = 0
    j = j + 10
    vertical_count = vertical_count + 1

    'If k < 5 Then
    'label1 = MyCols(k) & j
    'j = Workbooks("Destination0.xlsx").Sheets("Sheet1").Range(label1).Row
    'End If

    End If

    If vertical_count = 2 Then
    k = 1
    counter = 0
    vertical_count = vertical_count + 1
    j = 6

    'If k < 5 Then
    ' label1 = MyCols(k) & j
    ' j = Workbooks("Destination0.xlsx").Sheets("Sheet1").Range(label1).Row
    'End If

    End If
    End If


    Next i
    End Sub
    Attached Files Attached Files

  5. #5
    Registered User
    Join Date
    05-27-2009
    Location
    USA
    MS-Off Ver
    Excel 2007
    Posts
    22

    Re: How to create a button and automate the process of transferring data?

    anyways i am attaching the sheets and there is a code tooo....

    Thanks

+ 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