Reply
 
LinkBack Thread Tools Search this Thread Display Modes
  #1   Report Post  
Posted to microsoft.public.excel.programming
external usenet poster
 
Posts: 1,588
Default VBA Code Optimization

Something like this could serve as a general-purpose "find column" function:


Function GetCol(sVal as string) as long
dim f as range
Set f = Rows(1).Find(what:=sVal, LookIn:=xlValues)

if not f is nothing then
GetCol=f.column
else
GetCol=0
end if

end function



wrote in message
...
Hey all,

I am currently trying to optimize a set of code i wrote which creates
new spreadsheets, and fills their cells with data and equations pulled
from other source sheets. It is a very long set of code (some 869
lines) with alot of repeating cell-by-cell operations. Is there a way
to make the whole thing recursive, and possibly use objects instead of
lots of copied/pasted repeated code using nothing but simple
variables. If more detail or a sample of the code is necessary, i can
provide.

For example, part of my code searches for the location of a named cell
(column header), and assigns a variable its column position to use
later on with copy/paste operations when the new spreadsheet is
generated. This code is repeated MANY times, with different variable
names being subbed in....Any way to create and object out of this
process and just import the new variable names and set them in a
recursive way, instead of just duplicating this code:

Set Rcc = Rows(1).Find(what:="Rcc", LookIn:=xlValues)
If Not Rcc Is Nothing Then
myaddress = Mid(Rcc.Address, 2)
Rcccol = Left(myaddress, InStr(myaddress, "$") - 1)
End If

Any ideas or suggestions would be more than welcome. Thanks!

-Pogster



Reply
Thread Tools Search this Thread
Search this Thread:

Advanced Search
Display Modes

Posting Rules

Smilies are On
[IMG] code is On
HTML code is Off
Trackbacks are On
Pingbacks are On
Refbacks are On


Similar Threads
Thread Thread Starter Forum Replies Last Post
Excel code optimization deepika :excel help[_2_] Excel Discussion (Misc queries) 5 January 29th 08 01:02 PM
VBA Code Optimization for Array Formulas [email protected] Excel Programming 0 October 11th 07 06:46 PM
Seo , Search Engine Optimizer , Seo Search engine Optimization , search engine optimization services, SEO Consulting Se0 Guy Excel Discussion (Misc queries) 0 March 8th 07 04:08 AM
Code for optimization, ReDim Preserve not handling it well, HELP please! [email protected] Excel Programming 0 November 2nd 05 08:18 AM
Pivot Table - Code Optimization kaon[_35_] Excel Programming 3 August 20th 04 02:24 AM


All times are GMT +1. The time now is 06:50 AM.

Powered by vBulletin® Copyright ©2000 - 2025, Jelsoft Enterprises Ltd.
Copyright ©2004-2025 ExcelBanter.
The comments are property of their posters.
 

About Us

"It's about Microsoft Excel"