Dear Group,

I'm trying to extract a data from another workbook to another workbook. I
created this macro but it gives me an OUT of range error.
Please help.

Sub Bankreport()
    With Application
        .ScreenUpdating = False
        .DisplayAlerts = False
    End With
     Set rd = Workbooks("CDH02 payroll").Sheets("PayDbase") 'set read data
sheet as rd
    Set wd = Worksheets("BankList") 'set write data sheet as wd
    Worksheets("BankList").Range("B8:B10000").Clear ' clears the list region
   'the workbook cdh02 payroll is normally protected
   Workbooks("CDH02 Payroll").Unprotect
    Workbooks("CDH02 Payroll").Worksheets("Paydbase").Activate
    For i = 1 To rd.Range("E65536").End(xlUp).Row ' set i to the last row in
column b
        If Cells(i, 7) = wd.Range("d5").Value Then
            wd.Cells(wd.Range("E65536").End(xlUp).Row + 1, 5) = rd.Cells(i,
5)
        End If
    Next i
   'formatting report
   Worksheets("Banklist").Activate
    Application.Calculate
    Worksheets("Payreport").Range("a8").Select
    Selection.Copy
    Range("b8:b10000").Select
    Selection.PasteSpecial Paste:=xlPasteFormats, Operation:=xlNone, _
        SkipBlanks:=False, Transpose:=False
    Application.CutCopyMode = False
    Range("B8").Select
    'Worksheets("Payreport").Activate
    'Application.Calculate
    Application.ScreenUpdating = True
    Application.DisplayAlerts = True
    Workbooks("CDH02 Payroll").Protect

End Sub

-- 
----------------------------------------------------------------------------------
Some important links for excel users:
1. Follow us on TWITTER for tips tricks and links : 
http://twitter.com/exceldailytip
2. Join our LinkedIN group @ http://www.linkedin.com/groups?gid=1871310
3. Excel tutorials at http://www.excel-macros.blogspot.com
4. Learn VBA Macros at http://www.quickvba.blogspot.com
5. Excel Tips and Tricks at http://exceldailytip.blogspot.com
 
To post to this group, send email to excel-macros@googlegroups.com

<><><><><><><><><><><><><><><><><><><><><><>
HELP US GROW !!

We reach over 6,800 subscribers worldwide and receive many nice notes about the 
learning and support from the group.Let friends and co-workers know they can 
subscribe to group at http://groups.google.com/group/excel-macros/subscribe

Reply via email to