I'm trying to save a file but as a random name from a small list. This is what I have so far:
Option Explicit
Option Base 1
Public Sub SaveToDrive()
Dim categorys(5) As String
categorys(1) = "Adam"
categorys(2) = "James"
categorys(3) = "Henry"
categorys(4) = "William"
categorys(5) = "Keith"
ThisWorkbook.SaveAs Filename:="e:\" & categorys(Int((5 - 1 + 1) * Rnd + 1)).Name
End Sub
Currently, this returns an Invalid Qualifier error on "categorys" in the second to last line.
I'm completely new to VBA, but I was wondering if this was possible or if there was another/better way of doing it.
Thanks.
Aucun commentaire:
Enregistrer un commentaire