Re: Shorten Code

Tech-Archive recommends: Repair Windows Errors & Optimize Windows Performance



Here's how I would do your second example:

'1 Line
[A4:D4] = [{"Smith","97632","A",1}]

'or 2 Lines
[A5:D6] = [{"Pearson",95883,"B",1;"Gonzales",268603,"B",2}]

If you go crazy with too large an array, it can be hard to read and debug.

--
HTH :>)
Dana DeLouis
Windows XP & Office 2007


"Donna C" <DonnaC@xxxxxxxxxxxxxxxxxxxxxxxxx> wrote in message
news:DE1CAFC7-9FD4-432A-BCE9-F38992490A6B@xxxxxxxxxxxxxxxx
I am still pretty new to this so, you could put what I know about "arrays"
on
a pin head. I will try your code in a new workbook and try to understand
what
it does.Thanks for the input.
Donna C.

"Gary Keramidas" wrote:

i use this for a vacation calendar i wrote

arr = Array("MLK Day", "W/L Bday", "Memorial", "July 4th", "Labor", _
"Columbus", "Veteran's", "TGiving", "Closed", "Christmas")
i = 0

'For i = LBound(arr) To UBound(arr)
For Each cell In Worksheets("Blank
Form").Range("B19,C23,F32,H7,J7,K12,L13,L26,L27,M28")

cell.Value = arr(i)
cell.Font.Bold = True
cell.HorizontalAlignment = xlCenter
cell.Font.Size = 8
cell.Font.ColorIndex = 3
i = i + 1
Next


--


Gary


"Donna C" <DonnaC@xxxxxxxxxxxxxxxxxxxxxxxxx> wrote in message
news:33306CDE-D296-4961-BB52-CF205DACA384@xxxxxxxxxxxxxxxx
Hello again, I am trying to format a worksheet by running a macro. Here
are
some of my problem areas that I would like to condense if possible.

Example 1 Is a partial list of about 25 items that need to be added:
Range("H19").Select
ActiveCell.FormulaR1C1 = "Duty Groups"
Range("S19").Select
ActiveCell.FormulaR1C1 = "Hours"
Range("Y19").Select
ActiveCell.FormulaR1C1 = "Codes"
Range("E21").Select
ActiveCell.FormulaR1C1 = "Memorial Day"
Range("E22").Select
ActiveCell.FormulaR1C1 = "Labor Day"
Range("E23").Select
ActiveCell.FormulaR1C1 = "Christmas(December 25th)"
Range("K21").Select
ActiveCell.FormulaR1C1 = "New Years Day(Jan 1st)"
Range("K22").Select
ActiveCell.FormulaR1C1 = "Independance Day(July 4th)"
Range("K23").Select
ActiveCell.FormulaR1C1 = "Thanksgiving(4th Thursday in Nov)"

Example 2 Is a partial list of about 15 employees,their shift code
and
hours code:
Range("A4").Select
ActiveCell.FormulaR1C1 = "Smith"
Range("B4").Select
ActiveCell.FormulaR1C1 = "97632"
Range("C4").Select
ActiveCell.FormulaR1C1 = "A"
Range("D4").Select
ActiveCell.FormulaR1C1 = "1"
Range("A5").Select
ActiveCell.FormulaR1C1 = "Pearson"
Range("B5").Select
ActiveCell.FormulaR1C1 = "95883"
Range("C5").Select
ActiveCell.FormulaR1C1 = "B"
Range("D5").Select
ActiveCell.FormulaR1C1 = "1"
Range("A6").Select
ActiveCell.FormulaR1C1 = "Gonzales"
Range("B6").Select
ActiveCell.FormulaR1C1 = "268603"
Range("C6").Select
ActiveCell.FormulaR1C1 = "B"
Range("D6").Select
ActiveCell.FormulaR1C1 = "2"
Any thoughts on this???





.



Relevant Pages

  • Re: Shorten Code
    ... Thats really sweet and works great. ... "Dana DeLouis" wrote: ... If you go crazy with too large an array, it can be hard to read and debug. ...
    (microsoft.public.excel.programming)
  • Re: array and filehandle.
    ... but if the first element of the array is the mode ... any builtin with the function prototype. ... Only perl can parse Perl. ... Looking at code above I've got to crazy conclusion that there are some ...
    (comp.lang.perl.misc)
  • Re: K&R2, exercise 6.4
    ... but it is crazy to use both ... You may sort it later, but that is not the point. ... linked list and at the same time store every one in an array. ...
    (comp.lang.c)
  • Re: preg_replace_callback, carrying variables
    ... $ARRAY looks like this: ... Drives me crazy not to be able to use nowdocs in classes but that's another story... ...
    (comp.lang.php)
  • Re: preg_replace_callback, carrying variables
    ... $ARRAY looks like this: ... Drives me crazy not to be able to use nowdocs in classes but that's another story... ...
    (comp.lang.php)