Please check if the sheet name is "Pivot". if not then rename it to Pivot. On Thu, Jul 21, 2011 at 10:44 PM, Jorge Marques <leote.w...@gmail.com>wrote:
> Hi guys, i have this macro i use to copy a range from column D of a > worksheet of a workbook to column G of another workbook and worksheet, but > it keeps giving me the same error saying that it´s "subscript out of range" > in the line in yellow. > > Public wb, wbmes As Workbook > Sub filldatabase() > Call AbrirFile > Call left > wbmes.Close > End Sub > Private Sub AbrirFile() > Dim Filter, Caption As String > Dim SelectedFile As Variant > Set wb = ThisWorkbook > > Filter = "Ficheiro XLS (*.xls),(*.xls)" > Caption = "Escolha o ficheiro a importar..." > SelectedFile = Application.GetOpenFilename(Filter, , Caption) > If SelectedFile = False Then Exit Sub > Set wbmes = Workbooks.Open(SelectedFile, 1, 1) > End Sub > > Private Sub left() > Dim a As Double > wbmes.Activate > wbmes.Sheets("Total_Refrige").Select > wbmes.Sheets("Total_Refrige").Range(Range("D2"), > Range("D2").End(xlDown)).Copy > wb.Activate > If wb.Sheets("Pivot").Range("G2").Value <> "" Then > wb.Sheets("Pivot").Range("G1").End(xlDown).Offset(1, 0).Select > Else > wb.Sheets("Pivot").Range("G2").Select > End If > a = ActiveCell.Row > wb.Sheets("Total Refrige").Paste > Application.CutCopyMode = False > i = a > While wb.Sheets("Pivot").Range("G" & i).Value <> "" > i = i + 1 > > Wend > End Sub > > Do you have any idea how to solve this?1000 thanks > > -- > > ---------------------------------------------------------------------------------- > 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 > > <><><><><><><><><><><><><><><><><><><><><><> > Like our page on facebook , Just follow below link > http://www.facebook.com/discussexcel > -- ---------------------------------------------------------------------------------- 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 <><><><><><><><><><><><><><><><><><><><><><> Like our page on facebook , Just follow below link http://www.facebook.com/discussexcel