PDA

View Full Version : input same value in multiple cells



agnesz
07-31-2007, 01:06 PM
Hello there -
I have this code which selects various cells in one workbook and each cell needs to say a particular word. This code works, but I have a feeling that there's a much quicker and simpler way of writing it. Any thoughts?
This is what I'm currently using...

Range("B1").Select
ActiveCell.Formula = "MCE"
Range("d1").Select
ActiveCell.Formula = "MCE"
Range("f1").Select
ActiveCell.Formula = "MCE"
Range("h1").Select
ActiveCell.Formula = "MCE"
Range("j1").Select
ActiveCell.Formula = "MCE"
Range("l1").Select
ActiveCell.Formula = "MCE"
Range("n1").Select
ActiveCell.Formula = "MCE"
Range("p1").Select
ActiveCell.Formula = "MCE"
Range("r1").Select
ActiveCell.Formula = "MCE"
Range("t1").Select
ActiveCell.Formula = "MCE"
Range("v1").Select
ActiveCell.Formula = "MCE"

JKwan
07-31-2007, 01:57 PM
How about

Sub FillMCE()
For Index = 2 To 22 Step 2
Cells(1, Index).Value = "MCE"
Next Index
End Sub

rory
07-31-2007, 03:08 PM
You've already got the best solution, but for future reference in case you had an irregular set of columns, you can do this:
Range("B1,D1,F1,H1,J1,L1,N1,P1,R1,T1,V1").Formula = "MCE"

Regards,
Rory

agnesz
08-01-2007, 06:38 AM
super thank you!

agnesz
08-01-2007, 06:39 AM
:bow:
super thank you