+ Reply to Thread
Results 1 to 3 of 3

Copy from one workbook to a open workbook

  1. #1
    Registered User
    Join Date
    07-27-2011
    Location
    Santiago, Dominican Republic
    MS-Off Ver
    Excel 2010
    Posts
    5

    Copy from one workbook to a open workbook

    Hi, I know way to little of VBA, i need some help in copying values from one workbook to another workbook.... these is the problem.... I have book1.xls with some data, and book2.xlsm where i do the calculation.

    I want to search for a specific string values in a specific column (lets say "D") from rows 3 to the last filled row. if the value is true..... then copy the row in a sheet name "configuration" in the next blank row in book2.xlm.

    I'm sending a sample where i'm testing the formulas to see how far i can get. but i feel stuck at the moment.

    please help
    Attached Files Attached Files

  2. #2
    Registered User
    Join Date
    07-27-2011
    Location
    Santiago, Dominican Republic
    MS-Off Ver
    Excel 2010
    Posts
    5

    Re: Copy from one workbook to a open workbook

    Hello Again..... Well I'm still trying and this is my new code..... Please Help.. Still Getting the

    "Subscript out of range" Error

    Code:

    Sub CopyCopy()
    Dim rng1 As Range, rng2 As Range
    Dim i As Long
    Dim LastRowColB As Long, LastRowP As Long, InsertRow As Long

    LastRowColB = Workbooks("configuraciones_codigo_2.xls").Sheets("Codigo").Range("B65536").End(xlUp).Row
    LastRowP = Workbooks("calculos Pedidos_macro.xlsm").Sheets("configuraciones").Range("b65536").End(x1Up).Row
    InsertRow = LastRowP

    For i = 3 To LastRowColB

    If Workbooks("configuraciones_codigo_2.xls").Sheets("Codigo").Cells(i, 3).Value = "La Frontera Pallets" Then

    Set rng1 = Workbooks("configuraciones_codigo_2.xls").Sheets("codigo").Range(i, 1).EntireRow
    Set rng2 = Workbooks("calculos Pedidos_macro.xlsm").Sheets("Configuraciones").Range(InsertRow, 1).EntireRow
    rng1.Copy rng2

    InsertRow = InsertRow + 1
    Else
    Workbooks("vbf.xlsm").Sheets("MyDate").Range("A2") = 0

    End If
    Next i

    End Sub

  3. #3
    Registered User
    Join Date
    07-27-2011
    Location
    Santiago, Dominican Republic
    MS-Off Ver
    Excel 2010
    Posts
    5

    Re: Copy from one workbook to a open workbook

    Well..... since no reply to my problem i had to find the answer the hard way.

    this code is working for my, just wanted to posed a final code


    Sub Conf()

    Dim i As Integer
    Dim Source As Workbook
    Dim LastRow As Long
    Dim OriginalWorkBook As Workbook
    Set OriginalWorkBook = ThisWorkbook
    Const MyDir As String = "C:\Users\Shadow\Desktop\Frontera\Pedido de Madera\"
    Set Source = Workbooks.Open(MyDir & "configuraciones_codigo_2.xlsx")
    Application.ScreenUpdating = False
    LastRow = Source.Worksheets("codigo").Range("b" & Rows.Count).End(xlUp).Row

    For i = 3 To LastRow


    If Source.Worksheets("codigo").Cells(i, 3) = "La Frontera Pallets" Then

    Source.Worksheets("codigo").Rows(i).Copy


    OriginalWorkBook.Activate
    OriginalWorkBook.Worksheets("Configuraciones").Range("C65536").End(xlUp).Select
    ActiveCell.Offset(1, 0).Select
    Rows(ActiveCell.Row).Select
    Selection.PasteSpecial Paste:=xlPasteValues, Operation:=xlNone, SkipBlanks:= _
    False, Transpose:=False


    Else

    End If

    Next


    Application.ScreenUpdating = True

    End Sub

+ Reply to Thread

Thread Information

Users Browsing this Thread

There are currently 1 users browsing this thread. (0 members and 1 guests)

Tags for this Thread

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