Microsoft Office Forums

Go Back   Microsoft Office Forums > >

 
 
Thread Tools Display Modes
Prev Previous Post   Next Post Next
  #9  
Old 10-30-2017, 11:29 AM
FionaMcKenzie FionaMcKenzie is offline Help for VBA improvement Windows 10 Help for VBA improvement Office 2016
Novice
 
Join Date: Oct 2017
Location: Surrey, United Kingdom
Posts: 14
FionaMcKenzie is on a distinguished road
Default

Hi there,

With regards to this line of code have you considered using current region? If you use .End and there are gaps in your data ever it's not accurate. Whereas CurrentRegion is like clicking in a cell in a range and pressing Ctrl+Shift+* to work out the contiguous range even if there are gaps in any cells in the first column.

Rend = .Cells(.Rows.Count, "A").End(xlUp).Row

Change to:
Rend = .Range("A1").CurrentRegion.Rows.Count

Also seeing as you are reading so many lines of data from Excel, it may be quicker to make a SQL query using ADO.DB to get the data out of the source worksheet & output it to the destination worksheet. Once your SQL query is run, you do not need to loop through the recordset like you are through your worksheet.

If you write the correct SQL query you would get the result of your query, then you output the recordset result in one line of code,
e.g. oRange.CopyFromRecordset oADORecordSet - which would be quicker.

Kind regards
Reply With Quote
 

Tags
excel improvement, vba

Thread Tools
Display Modes


Similar Threads
Thread Thread Starter Forum Replies Last Post
Help for VBA improvement forum platform – room for improvement eNGiNe Forum Support 1 09-14-2016 04:14 PM
Help for VBA improvement Process Improvement Project Plan raminraiszadeh Project 1 04-05-2016 06:05 AM
Form improvement edayers315 Word 0 08-19-2011 09:55 AM

Other Forums: Access Forums

All times are GMT -7. The time now is 03:32 PM.


Powered by vBulletin® Version 3.8.11
Copyright ©2000 - 2025, vBulletin Solutions Inc.
Search Engine Optimisation provided by DragonByte SEO (Lite) - vBulletin Mods & Addons Copyright © 2025 DragonByte Technologies Ltd.
MSOfficeForums.com is not affiliated with Microsoft