LinkBack Thread Tools Search this Thread Display Modes
Prev Previous Post   Next Post Next
  #8   Report Post  
Posted to microsoft.public.excel.programming
external usenet poster
 
Posts: 411
Default Trouble exporting using Chip Pearson's export

Thank you Joel.

'There are two last rows
LastRow = .Cells(Rows.Count, "A").End(xlUp).Row
'LastRow = ActiveCell.SpecialCells(xlCellTypeLastCell).Row
LastCol = .Cells(1, Columns.Count).End(xlToLeft).Column

'Not sure what this is doing?
'Sheets.Item(A1).Select



I was trying to determine what sheet the procedure was operating on
and I neglected to remove the test. Since you added the "With" clause,
the procedure is working.

Thanks for your attention and help.

Dan

On Sep 27, 5:49 pm, Joel wrote:
I started using the with statement to make sure I'm on the correct sheet and
avoid using the select method unless absolutely necessary. Some methods only
work with select.

The set MyRange statement would fail if LastRow or LastCol were not valid.
Private Sub cmdComplete_Click()
Dim MyRange As Range
Dim LastRow As Long
Dim LastCol As Long

with Sheets("CompleteQuote")
'There are two last rows
LastRow = .Cells(Rows.Count, "A").End(xlUp).Row
'LastRow = ActiveCell.SpecialCells(xlCellTypeLastCell).Row
LastCol = .Cells(1, Columns.Count).End(xlToLeft).Column

'Not sure what this is doing?
'Sheets.Item(A1).Select

Set MyRange = .Range("A19", .Cells(LastRow, LastCol))

'LastRow.Select
'MyRange.Select
DoTheExport
Clear_Unlocked2
.Range("A19:G65536").ClearContents
txtCount = 0
end with
Sheets("QuotedPart").Activate
End Sub

Hi Joel,

I've been debugging using F8. To get the yellow highlight to move
through the code, I had to dim MyRange, LastRow and LastCol. I'm not
sure how they should be dimensioned. . .So I chose as Range for
MyRange, as Long for LastRow and LastCol.

Anyway these variables show the last row is 87. I deleted blank rows
below my data and closed the workbook--it still shows last row as 87.
When I look at the spreadsheet it looks like the last row is 68.

I suspect MyRange, LastRow and Last Column are calculating on a sheet
other than my intended sheet. I don't know how to determine where the
procedure is getting the values.

MyRange returns an error--"Run-time error '1004': Application-defined
or object-defined error"

I suspect this is because I am running a private procedure from a
button on the sheet, QuotedPart, that is manipulating a different
sheet, CompletedQuote.

Do you have any further feedback?

Thanks,

Dan

Private Sub cmdComplete_Click()
Dim MyRange As Range
Dim LastRow As Long
Dim LastCol As Long
Sheets("CompleteQuote").Activate
Sheets.Item(A1).Select
LastRow = Cells(Rows.Count, "A").End(xlUp).Row
LastCol = Cells(1, Columns.Count).End(xlToLeft).Column

LastRow = ActiveCell.SpecialCells(xlCellTypeLastCell).Row

Set MyRange = Range("A19", Cells(LastRow, LastCol))

'LastRow.Select
'MyRange.Select
DoTheExport
Clear_Unlocked2
Worksheets("CompleteQuote").Range("A19:G65536").Cl earContents
txtCount = 0
Sheets("QuotedPart").Activate
End Sub



 
Thread Tools Search this Thread
Search this Thread:

Advanced Search
Display Modes

Posting Rules

Smilies are On
[IMG] code is On
HTML code is Off
Trackbacks are On
Pingbacks are On
Refbacks are On


Similar Threads
Thread Thread Starter Forum Replies Last Post
Chip Pearson's NewWorkDays formula Pete Rooney Excel Discussion (Misc queries) 9 August 9th 08 01:57 AM
DeleteDuplicatesViaFilter From Chip Pearson's Website JohnHB Excel Programming 1 April 11th 07 09:06 PM
How to Use Chip Pearson's Text Import Code [email protected] Excel Programming 12 August 23rd 06 02:28 PM
Chip Pearson's Forum Etiquette Gary L Brown New Users to Excel 0 January 20th 06 07:22 PM
Help with Chip Pearson's Code for Deleting Blank Rows Rashid Khan Excel Programming 6 June 30th 04 08:53 PM


All times are GMT +1. The time now is 05:56 AM.

Powered by vBulletin® Copyright ©2000 - 2025, Jelsoft Enterprises Ltd.
Copyright ©2004-2025 ExcelBanter.
The comments are property of their posters.
 

About Us

"It's about Microsoft Excel"