Results 1 to 4 of 4

Thread: [RESOLVED] How does Excel set the used range?

  1. #1

    Thread Starter
    Hyperactive Member
    Join Date
    Apr 2002
    Posts
    382

    Resolved [RESOLVED] How does Excel set the used range?

    Is there a dependable way to cause Excel to set the used range (i.e., last row, last column) of a worksheet other than saving the workbook? I have an application where I filter a sheet and then delete all visible rows. When I copy that sheet to another sheet, the used ranges of each sheet do not agree. By accident, if I msgbox the function xllastrow of each sheet, then they agree. But I don't want to msgbox and I don't want to save teh workbook. Thanks.

  2. #2
    PowerPoster
    Join Date
    Oct 2008
    Location
    Midwest Region, United States
    Posts
    3,574

    Re: How does Excel set the used range?

    What are you doing with the "used range" that requires them to agree?

  3. #3

    Thread Starter
    Hyperactive Member
    Join Date
    Apr 2002
    Posts
    382

    Re: How does Excel set the used range?

    I am filtering Sheet1 and removing all rows that I do not need. Then I am copying Sheet1 using 'Move or Copy'. Then I want to replace all formulas on Sheet1 (2) by using 'ActiveSheet.UsedRange.Value = Sheets("Imported Data").UsedRange.Value'. Sheet1 (2) ends up with #NA rows at the end of sheet. The number of #NA rows is exactly the number of rows that I deleted on Sheet1. I've tried to active sheet calculate but that ddoesn't work. When I msgbox xlLastRow("Sheet1"), it displays the correct row number, but it is copying beyond that row. If I msgbox the Sheet1.usedrange before I copy, then the correct number of rows is copied.

  4. #4

    Thread Starter
    Hyperactive Member
    Join Date
    Apr 2002
    Posts
    382

    Re: How does Excel set the used range?

    I got around the problem by calculating the Sheet1.usedrange before copying. Thanks.

Posting Permissions

  • You may not post new threads
  • You may not post replies
  • You may not post attachments
  • You may not edit your posts
  •  



Click Here to Expand Forum to Full Width