Re: Clean Up Code - consolidate steps

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



There is no pattern to the values so the simplest thing is to simplify the
code

Range("A1").Value = "USB"
Range("A2").Value = "04165"
Range("A3").Value = "14709"
Range("A4").Value = "14716"
Range("A5").Value = "24704"
Range("A6").Value = "44705"
Range("A7").Value = "44710"

You could also load an array

aryValues = Array("USB", "04165", "14709", "14716", "24704", "44705",
"44710")
For i = 0 To UBound(aryValues)
Range("A" & i + 1).Value = aryValues(i)
Next i


--
HTH

Bob Phillips

"Frantic Excel-er" <FranticExceler@xxxxxxxxxxxxxxxxxxxxxxxxx> wrote in
message news:5F27D57A-DDF5-46F1-A9E4-CE2187D09679@xxxxxxxxxxxxxxxx
> Hi All...
>
> I have code that contains the following:
>
> ActiveCell.FormulaR1C1 = "USB"
> Range("A2").Select
> ActiveCell.FormulaR1C1 = "04165"
> Range("A3").Select
> ActiveCell.FormulaR1C1 = "14709"
> Range("A4").Select
> ActiveCell.FormulaR1C1 = "14716"
> Range("A5").Select
> ActiveCell.FormulaR1C1 = "24704"
> Range("A6").Select
> ActiveCell.FormulaR1C1 = "44705"
> Range("A7").Select
> ActiveCell.FormulaR1C1 = "44710"
>
> and it goes on to enter the associated text on the next line...all the way
> down to 60 rows. Is there a way that I can consolidate these steps where
the
> macro will automatically know to put the text in the next rows......for
> example....
> MACRO CODE = Enter Text, start A1...FAS,12354, 23456
>
>
>
>
>


.



Relevant Pages

  • Re: fast stable sort
    ... For fastest load, at expense of slower sort, you ask the operating ... and you memory-map the file directly into that array. ... memory of your big array. ... possible to assure locality of reference and thus avoid thrashing ...
    (comp.programming)
  • Re: Controller for Switching current sink
    ... The load, includes ... the switch closed with my monster-FET array. ... So, I'm gonna precharge the cap, then throw the switch at 0v. ... I calculate 1.5 joules in the cap, so the fet has to dump the same 1.5 ...
    (sci.electronics.design)
  • Re: Program Fails When Parameter Fixed Constants are Changed (F77) ??
    ... ,>There are for module procedures, but it doesn't look like ... simplest combination that mimics the compilation/linker problem. ... ,>Simplify, simplify, simplify... ...
    (comp.lang.fortran)
  • Re: Compact
    ... How many cells does excel think you are using. ... The number of forms and controls on forms could load the program down. ... Simplify your code modules. ...
    (microsoft.public.excel.programming)
  • Re: How can I create a 2D ArrayList? String usually.
    ... I basically would like a 2 column array or whatever that will be static, ... in values won't change after I load them and I would like to fairly quickly ... > Array.IndexOf is probably going to yield linear performance as you add ... you might be better off using hashtables. ...
    (microsoft.public.dotnet.languages.csharp)