0

I would like to populate all of the selected cells in a PowerPoint table with randomly generated numbers using PowerPoint VBA.

I am able to insert a randomly generated number at the current cursor position using this sub-routine:

Sub RandomNumberGenerator()
    Dim oRange As TextRange
    Set oRange = ActiveWindow.Section.TextRange.Characters
    oRange.Text = Int(Rnd()*10000)
End Sub 

How can I extend it to fill in random numbers in all selected cells of a Table?

Martijn Pieters
  • 1,048,767
  • 296
  • 4,058
  • 3,343
tchakravarty
  • 10,736
  • 12
  • 72
  • 116

1 Answers1

0

You need to first determine that the selection shape range includes a table and then loop through the rows and columns, checking to see if each cell is selected and if it is, insert your random number text into the cell's corresponding shape object.

Jamie Garroch - MVP
  • 2,839
  • 2
  • 16
  • 24