select only the data necessary in this code

excel 2010 vba

Is there a way to change the code below to only select the used data on the sheet?




Dim curWks As Worksheet
Dim templWks As Worksheet
Dim rngToCopy As Range

   On Error GoTo OpeniFinalCustomerWorkbook_Error

Set curWks = ActiveSheet
With curWks
Set rngToCopy = .Range("A1:AU65453", .Range("a1").End(xlToRight).End(xlDown))

Open in new window


Thanks
fordraiders
LVL 3
FordraidersAsked:
Who is Participating?
I wear a lot of hats...

"The solutions and answers provided on Experts Exchange have been extremely helpful to me over the last few years. I wear a lot of hats - Developer, Database Administrator, Help Desk, etc., so I know a lot of things but not a lot about one thing. Experts Exchange gives me answers from people who do know a lot about one thing, in a easy to use platform." -Todd S.

redmondbCommented:
Hi, fordraiders.

.UsedRange

Regards,
Brian.
0

Experts Exchange Solution brought to you by

Your issues matter to us.

Facing a tech roadblock? Get the help and guidance you need from experienced professionals who care. Ask your question anytime, anywhere, with no hassle.

Start your 7-day free trial
FordraidersAuthor Commented:
Set rngToCopy = .Range("A1:AU65453", .UsedRange)
?

fordraiders
0
SteveCommented:
Dim curWks As Worksheet
Dim templWks As Worksheet
Dim rngToCopy As Range

   On Error GoTo OpeniFinalCustomerWorkbook_Error

Set curWks = ActiveSheet

Set rngToCopy = curWks.UsedRange

Open in new window


could you post the full code... as the code you have there can be shortened to:

Dim templWks As Worksheet
Dim rngToCopy As Range

   On Error GoTo OpeniFinalCustomerWorkbook_Error

Set rngToCopy = ActiveSheet.UsedRange

Open in new window

(no real need for dimming and setting curWks)
0
Cloud Class® Course: CompTIA Healthcare IT Tech

This course will help prep you to earn the CompTIA Healthcare IT Technician certification showing that you have the knowledge and skills needed to succeed in installing, managing, and troubleshooting IT systems in medical and clinical settings.

FordraidersAuthor Commented:
Thanks
0
redmondbCommented:
Thanks, fordraiders (and Steve!).

BTW, if there's any chance that the first row might be blank, it might be safer to use...
Set rngToCopy = Range("A1", ActiveSheet.UsedRange)
(UsedRange "starts" from the first non-blank row and column.)

Regards,
Brian.
0
SteveCommented:
No worries Brian, I'm sure you had it covered anyways :)

ATB
Steve.
0
It's more than this solution.Get answers and train to solve all your tech problems - anytime, anywhere.Try it for free Edge Out The Competitionfor your dream job with proven skills and certifications.Get started today Stand Outas the employee with proven skills.Start learning today for free Move Your Career Forwardwith certification training in the latest technologies.Start your trial today
Microsoft Excel

From novice to tech pro — start learning today.