Sign Up

Sign Up to our social questions and Answers Engine to ask questions, answer people’s questions, and connect with other people.

Have an account? Sign In

Have an account? Sign In Now

Sign In

Login to our social questions & Answers Engine to ask questions answer people’s questions & connect with other people.

Sign Up Here

Forgot Password?

Don't have account, Sign Up Here

Forgot Password

Lost your password? Please enter your email address. You will receive a link and will create a new password via email.

Have an account? Sign In Now

You must login to ask a question.

Forgot Password?

Need An Account, Sign Up Here

Please briefly explain why you feel this question should be reported.

Please briefly explain why you feel this answer should be reported.

Please briefly explain why you feel this user should be reported.

Sign InSign Up

The Archive Base

The Archive Base Logo The Archive Base Logo

The Archive Base Navigation

  • SEARCH
  • Home
  • About Us
  • Blog
  • Contact Us
Search
Ask A Question

Mobile menu

Close
Ask a Question
  • Home
  • Add group
  • Groups page
  • Feed
  • User Profile
  • Communities
  • Questions
    • New Questions
    • Trending Questions
    • Must read Questions
    • Hot Questions
  • Polls
  • Tags
  • Badges
  • Buy Points
  • Users
  • Help
  • Buy Theme
  • SEARCH
Home/ Questions/Q 7049917
In Process

The Archive Base Latest Questions

Editorial Team
  • 0
Editorial Team
Asked: May 28, 20262026-05-28T03:04:46+00:00 2026-05-28T03:04:46+00:00

From the current workbook, I want to open a sheet in the source workbook,

  • 0

From the current workbook, I want to open a sheet in the source workbook, turn off any filtering that may be present, sort by one column, then another, then another. Am getting 1004 and other errors. This needs to run on 2003. Any help will be appreciated!

Dim WB As Workbook, WasWBOpen As Boolean, srcfile As String, srcpath As String,    
onecol as integer, twocol as integer, thrcol as integer

srcpath = "blahblah"
srcfile = "blah.xls"

On Error Resume Next
Set WB = Workbooks(srcfile)
WasWBOpen = True
On Error GoTo 0
If WB Is Nothing Then
Set WB = Workbooks.Open(srcpath & srcfile, UpdateLinks:=False)
WasWBOpen = False
End If

'code before this opens source wkbook

lstrow = Worksheets("Sheet1").UsedRange.Row - 1 + Worksheets("Sheet1").UsedRange.Rows.Count
lstcol = Worksheets("Sheet1").UsedRange.Column - 1 + Worksheets("Sheet1").UsedRange.Columns.Count

onecol=3
twocol=5
thrcol=8

With WB.Sheets("Sheet1")

.AutoFilterMode = False
.Range("1:1").AutoFilter
'Here's where error occurs--
.Range(Cells(1, 1), Cells(lstrow, lstcol)).Sort _
    Key1:=Columns(onecol), Order1:=xlAscending, _
    Key2:=Columns(twocol), Order2:=xlAscending, _
    Key3:=Columns(thrcol), Order3:=xlAscending, Header:=xlYes

End With

If WasWBOpen = False Then
WB.Close
End If
  • 1 1 Answer
  • 0 Views
  • 0 Followers
  • 0
Share
  • Facebook
  • Report

Leave an answer
Cancel reply

You must login to add an answer.

Forgot Password?

Need An Account, Sign Up Here

1 Answer

  • Voted
  • Oldest
  • Recent
  • Random
  1. Editorial Team
    Editorial Team
    2026-05-28T03:04:47+00:00Added an answer on May 28, 2026 at 3:04 am
    .Range(Cells(1, 1), Cells(lstrow, lstcol)).Sort _ 
    

    is better written as:

    .Range(.Cells(1, 1), .Cells(lstrow, lstcol)).Sort _ 
    
    • 0
    • Reply
    • Share
      Share
      • Share on Facebook
      • Share on Twitter
      • Share on LinkedIn
      • Share on WhatsApp
      • Report

Sidebar

Related Questions

I want to pass an exception from current thread (that thread isn't main thread)to
I want to get text from current active line (the line where the caret
Want to send the text from my current vb application to the Active Window
I want to be able to switch from the current db to multiple dbs
I have a code sample that gets a SEL from the current object, SEL
I want to redirect from current page to previous page.. I want this previous
How to convert 2011-11-03T17:27:56Z to time in php. I want time difference from current
I want to search in all files from the current folder for macro CODE_INIT_PARAMETERS
How do I activate my Other workbook from the Current workbook? I have a
I have a jquery-code which using selectors (from current document). Now I want to

Explore

  • Home
  • Add group
  • Groups page
  • Communities
  • Questions
    • New Questions
    • Trending Questions
    • Must read Questions
    • Hot Questions
  • Polls
  • Tags
  • Badges
  • Users
  • Help
  • SEARCH

Footer

© 2021 The Archive Base. All Rights Reserved
With Love by The Archive Base

Insert/edit link

Enter the destination URL

Or link to existing content

    No search term specified. Showing recent items. Search or use up and down arrow keys to select an item.