0

hey guys i have this small piece of code:

If IsEmpty(Cells(8, M8).Value) And IsEmpty(Cells(14, M8).Value) = True Then
                                    Sheets("Schedule").Cells(8, M8).Value = info
                                    Sheets("Schedule").Range(Cells(9, M8), Cells(14, M8)).Value = ","
                                    Sheets("Schedule").Range(Cells(8, M8), Cells(14, M8)).Interior.Color = rcolor
                                    Sheets("Schedule").Range(Cells(8, M8), Cells(14, M8)).BorderAround Weight:=xlMedium
                                    M8 = M8 + 1
                                    Else
                                    M8 = M8 + 1
                                    End If

and i want instead of printing a comma on the empty cells beneath the cell with the "info" init, i want all the info to be printed onto the cells under the main cell lets say, since the info is has a lot of words/aka quite large

1 Answers1

0

First, you should use With, when referencing a sheet that many times. Also, it helps with anchoring the Cells() to the sheet you expect them to be on:

With Sheets("Schedule")
If IsEmpty(.Cells(8, M8).Value) And IsEmpty(.Cells(14, M8).Value) Then
    .Cells(8, M8).Value = info
    .Range(.Cells(9, M8), .Cells(14, M8)).Value = ","
    .Range(.Cells(8, M8), .Cells(14, M8)).Interior.Color = rcolor
    .Range(.Cells(8, M8), .Cells(14, M8)).BorderAround Weight:=xlMedium
    M8 = M8 + 1
Else
    M8 = M8 + 1
End If

But for your main question, can you clarify? Why not just replace the "," with info? Perhaps post a sample table of what you expect the output to look like?

BruceWayne
  • 22,923
  • 15
  • 65
  • 110
  • you see if i replace , with info then i would have info repeated like 5 or 6 times and in other cases even more, i want just one info to be outputted on all the cells in the range i want (as you can see above) hope this clears things out – Ghaith Haddad Jun 20 '16 at 18:17