LinkBack Thread Tools Search this Thread Display Modes
Prev Previous Post   Next Post Next
  #1   Report Post  
Posted to microsoft.public.excel.programming
external usenet poster
 
Posts: 12
Default Declaring Offset as a variable

Hi All

I have a VBA project which works fine but I'd like to improve my coding
style. In this project the user selects a cell in one sheet then a different
cell in another. Several checks are made on various values then the contents
of the corresponding row in the 1st sheet are copied to the second. For
historical reasons, the layout of the columns differs between the two sheets
(of course!) so the code boiled down to a bunch of statements like:

'NoteBook
mySht.Cells(myRow, dstNotebk) = ActiveCell.Offset(0, srcNotebk)
'Concentration
mySht.Cells(myRow, dstConc) = ActiveCell.Offset(0, srcConc)

where the variables dstNotebk etc. are declared as constants (e.g. const
dstConc = 5) and the source sheet is Active.

I'd like to neaten it up, for example allowing a syntax like

mySht.dstNotebk = ActiveCell.srcNotebk

i.e. have dstNotebk be a variable storing Cells(myRow,dstNotebk) and
srcNotebk storing Offset(0,srcNotebk). Is this possible? Is there a better
way to tackle this problem?

Thanks for any help!


 
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
Can a variable be used when declaring an API call ? Mike Iacovou Excel Programming 3 July 23rd 07 03:19 AM
Declaring a tab name as a variable timmulla Excel Programming 2 January 25th 07 05:16 AM
Declaring a tab name as a variable timmulla Excel Programming 0 January 25th 07 03:26 AM
Declaring Variable as VBConstant The Vision Thing Excel Programming 2 May 15th 04 06:35 PM
Declaring a variable? pgoodale[_4_] Excel Programming 2 January 2nd 04 03:26 PM


All times are GMT +1. The time now is 11:28 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"