ExcelBanter

ExcelBanter (https://www.excelbanter.com/)
-   Excel Worksheet Functions (https://www.excelbanter.com/excel-worksheet-functions/)
-   -   Please, somebody look at this code : ( (https://www.excelbanter.com/excel-worksheet-functions/122462-please-somebody-look-code.html)

justme

Please, somebody look at this code : (
 
Sub GetData()
Dim origin As String
Dim orgn As Workbook, dest As Workbook
Dim ws As Worksheet
Dim wsIr As Worksheet

Dim Firstrow As Long
Dim LastRow As Long
Dim Lrow As Long

Set wsIr = Sheets("INTLraw")

wsIr.Activate
Range("A1").Select

Application.ScreenUpdating = False
origin = Application.GetOpenFilename("Microsoft Office Excel
Files(*.xl*;*.xls;*.xla;*.xlm;*.xlc;*.xlw),*.xl*;* .xls;*.xla;*.xlm;*.xlc;*.xlw")
If origin = "False" Then Exit Sub
Workbooks.Open origin, 0, True
Set orgn = ActiveWorkbook
orgn.Activate
Sheets(2).Activate

Firstrow = ActiveSheet.UsedRange.Cells(1).Row
LastRow = ActiveSheet.UsedRange.Rows.Count + Firstrow - 1

With ActiveSheet
..DisplayPageBreaks = False
End With

With orgn.Sheets(2)
LastRow = wsIr.Cells(Rows.Count, "I").End(xlUp).Row
Set MyRange = wsIr.Cells(LastRow, "I").Offset(1, -8)
..Range("A1", .Cells.SpecialCells(xlCellTypeLastCell)).Copy
Destination:=MyRange.Paste
End With
WSI.Activate

End Sub



I am having problems with the line near the end reading ".Range("A1",......"

Causes run-time error: Object doesn't support this property or method.

Help?


Dave Peterson

Please, somebody look at this code : (
 
Drop the .paste from that line and I'd change the order--just for ease of
reading.


LastRow = wsIr.Cells(Rows.Count, "I").End(xlUp).Row
Set MyRange = wsIr.Cells(LastRow, "I").Offset(1, -8)

With orgn.Sheets(2)
.Range("A1", .Cells.SpecialCells(xlCellTypeLastCell)).Copy _
Destination:=MyRange
End With



justme wrote:

Sub GetData()
Dim origin As String
Dim orgn As Workbook, dest As Workbook
Dim ws As Worksheet
Dim wsIr As Worksheet

Dim Firstrow As Long
Dim LastRow As Long
Dim Lrow As Long

Set wsIr = Sheets("INTLraw")

wsIr.Activate
Range("A1").Select

Application.ScreenUpdating = False
origin = Application.GetOpenFilename("Microsoft Office Excel
Files(*.xl*;*.xls;*.xla;*.xlm;*.xlc;*.xlw),*.xl*;* .xls;*.xla;*.xlm;*.xlc;*.xlw")
If origin = "False" Then Exit Sub
Workbooks.Open origin, 0, True
Set orgn = ActiveWorkbook
orgn.Activate
Sheets(2).Activate

Firstrow = ActiveSheet.UsedRange.Cells(1).Row
LastRow = ActiveSheet.UsedRange.Rows.Count + Firstrow - 1

With ActiveSheet
.DisplayPageBreaks = False
End With

With orgn.Sheets(2)
LastRow = wsIr.Cells(Rows.Count, "I").End(xlUp).Row
Set MyRange = wsIr.Cells(LastRow, "I").Offset(1, -8)
.Range("A1", .Cells.SpecialCells(xlCellTypeLastCell)).Copy
Destination:=MyRange.Paste
End With
WSI.Activate

End Sub

I am having problems with the line near the end reading ".Range("A1",......"

Causes run-time error: Object doesn't support this property or method.

Help?


--

Dave Peterson

justme

Please, somebody look at this code : (
 
GENIUS! That's what you are!

thanks for responding, even though I posted in the wrong forum.

:) :) :) :) :)


All times are GMT +1. The time now is 06:50 PM.

Powered by vBulletin® Copyright ©2000 - 2024, Jelsoft Enterprises Ltd.
ExcelBanter.com