D
Dennis Benjamin
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!
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!