-
input same value in multiple cells
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"
-
How about
[vba]
Sub FillMCE()
For Index = 2 To 22 Step 2
Cells(1, Index).Value = "MCE"
Next Index
End Sub
[/vba]
-
You've already got the best solution, but for future reference in case you had an irregular set of columns, you can do this:
[VBA] Range("B1,D1,F1,H1,J1,L1,N1,P1,R1,T1,V1").Formula = "MCE"[/VBA]
Regards,
Rory
-
-
super thank you
Posting Permissions
- You may not post new threads
- You may not post replies
- You may not post attachments
- You may not edit your posts
-
Forum Rules