+ Reply to Thread
Results 1 to 3 of 3

Pasting data in every other column

  1. #1
    Forum Contributor
    Join Date
    05-06-2004
    Posts
    117

    Pasting data in every other column

    Greetings to all, please do not be fooled by the code below. I really do not know that much about VBA. All that I have done is piece together code that I have obtained from this forum from some very helpful people. Currently, I am trying to paste data from various sources into one sigle sheet on everyother column. However, I can get the code up to the point where it retrieves the data from all the data sources, but I can only get it to paste into C8 of the one sheet where i want to bring my data together. Ideally, I want to paste data from the first source in column C8, data from the second data source in column E8 and so forth and so on up to column AK8. Can some one advise me as to what to do? I really appreciate the help. Thank you
    Sub GetData()
    Dim File As Variant
    Set File = Sheets("Specs").Range("A8:A25")
    ThisFile = ThisWorkbook.Name
    Pathname = Sheets("Specs").Range("B6").Value
    For Each c In Worksheets("Specs").Range("A8:A25")
    Filename = c.Offset(0, 1).Value
    With File
    Workbooks.Open Filename:=Pathname & Filename
    Windows(Filename).Activate
    Sheets("Generation Deviation").Activate
    Range("I5:I748").Select
    Selection.Copy
    ActiveWindow.Close

    Windows(ThisFile).Activate
    Sheets("INPUT").Select
    Range("C8").Select
    Selection.PasteSpecial 'Paste:=xlPasteAll, Operation:=xlNone, SkipBlanks:= _
    'False, Transpose:=False
    End With

    Next c
    End Sub

  2. #2
    Valued Forum Contributor
    Join Date
    07-11-2004
    Posts
    851
    I'm no expert but here is what I would try (inserts in caps)

    Sub GetData()
    Dim File As Variant
    Set File = Sheets("Specs").Range("A8:A25")
    ThisFile = ThisWorkbook.Name
    Pathname = Sheets("Specs").Range("B6").Value
    '
    AA = 1
    '
    For Each c In Worksheets("Specs").Range("A8:A25")
    Filename = c.Offset(0, 1).Value
    '
    AA = AA + 2
    '
    With File
    Workbooks.Open Filename:=Pathname & Filename
    Windows(Filename).Activate
    Sheets("Generation Deviation").Activate
    Range("I5:I748").Select
    Selection.Copy
    ActiveWindow.Close

    Windows(ThisFile).Activate
    Sheets("INPUT").Select
    '
    CELLS(8,AA).SELECT
    '
    Selection.PasteSpecial 'Paste:=xlPasteAll, Operation:=xlNone, SkipBlanks:= _
    'False, Transpose:=False
    End With

    Next c
    End Sub
    not a professional, just trying to assist.....

  3. #3
    Forum Contributor
    Join Date
    05-06-2004
    Posts
    117
    Duane,
    Thank you for your response. I have tried the additions to the macro, but something is missing. I do kind of see what you were to get done and I am grateful for the suggestion. When i run the macro with the inserts, it no longer seems to recognize the files that i am trying to open. Please do not stop the suggestions, every singel piece of advice allows me to learn somthing else.

+ 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