Thread: Variable coding
View Single Post
  #1   Report Post  
Posted to microsoft.public.excel.programming
Dave[_9_] Dave[_9_] is offline
external usenet poster
 
Posts: 12
Default Variable coding

I have programmed an excel "form" to dump data entry into a "sheet" in the
same work book.

On the save button:
Worksheets("Successor").Range("b2").Value = cboPositionID1
Worksheets("Successor").Range("c2").Value = cboReadiness1
Worksheets("Successor").Range("d2").Value = txtDev1

On the form initulitazion:
Me.cboPositionID1.Value = Worksheets("Successor").Range("b2").Value
Me.cboReadiness1.Value = Worksheets("Successor").Range("c2").Value
Me.txtDev1.Value = Worksheets("Successor").Range("d2").Value

These are 3 fields for ONE row on the form.
However, I need to make 20 rows with the same 3 fields and they would dump
in to successive rows

Example
Row 1 field1
Worksheets("Successor").Range("b2").Value = cboPositionID1

Row 2 field 1
Worksheets("Successor").Range("b3").Value = cboPositionID2

And so on.
So - not too hard to program but also way more code then necessary.

Something more elegant would be to have variables for:
Cell row number
&
Field number (cboPositionID1 or 2 or 3....)

Example:
Worksheets("Successor").Range("bVarialble").Value = cboPositionIDVariable

Can someone help me write that?

Hope I have explained what I need

Any help here will be appreciated.

Thanks in advance

dave