Logo 
Search:

MS Office Answers

Ask Question   UnAnswered
Home » Forum » MS Office       RSS Feeds
  Question Asked By: Colleen Burton   on Mar 03 In MS Office Category.

  
Question Answered By: Francis Riley   on Mar 03

What I would do to ensure that you get what you want, is I would modify
your code just a little:

'Make sure you use whatever the name of the sheet  that you are going to
import
Worksheets("Sheet1").Activate
ActiveSheet.UsedRange.Select
Selection.Sort Key1:=Range("A2"), Order1:=xlDescending,
Header:=xlGuess, _
OrderCustom:=1, MatchCase:=False, Orientation:=xlTopToBottom

You don't need the scrolling movements, because they were recorded as
you were confirming that everything was selected and that it worked
before you turned off the recorder.

The ActiveSheet.UsedRange.Select makes sure that you include all cells
that have any values in them. Which should eliminate the problem that
you have with making sure you don't miss cells/rows that have been added
since the last time you run the code.

Yes, you can save the file with a new location and file name to use in
your import.

ChDir "C:\"
ActiveWorkbook.SaveAs Filename:= _
"C:\ToBeImported.xls" _
, FileFormat:=xlNormal, Password:="", WriteResPassword:="", _
ReadOnlyRecommended:=False, CreateBackup:=False

Share: 

 

This Question has 10 more answer(s). View Complete Question Thread

 
Didn't find what you were looking for? Find more on Question about importing Excel. Or get search suggestion and latest updates.


Tagged: