Consulting

Results 1 to 5 of 5

Thread: input same value in multiple cells

  1. #1
    VBAX Regular
    Joined
    May 2007
    Posts
    72
    Location

    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"

  2. #2
    VBAX Expert
    Joined
    Aug 2004
    Posts
    810
    Location
    How about
    [vba]
    Sub FillMCE()
    For Index = 2 To 22 Step 2
    Cells(1, Index).Value = "MCE"
    Next Index
    End Sub
    [/vba]

  3. #3
    VBAX Master
    Joined
    Jun 2007
    Location
    East Sussex
    Posts
    1,110
    Location
    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

  4. #4
    VBAX Regular
    Joined
    May 2007
    Posts
    72
    Location
    super thank you!

  5. #5
    VBAX Regular
    Joined
    May 2007
    Posts
    72
    Location

    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
  •