I am looking to take a string of digits produced by my VBA code from a Get Busy Info query into separate cells in excel. i.e. all digits have a separate cell and not all clumped as a string in one cell which is my current issue.
Thanks
Public Sub GetFreeBusyInfo()
'launch Outlook
Dim olapp As Outlook.Application
Set olapp = CreateObject("Outlook.Application")
Dim myNameSpace As Outlook.Namespace
Set myNameSpace = olapp.GetNamespace("MAPI")
Dim myRecipient As Outlook.Recipient
' who's calendar
Set myRecipient = myNameSpace.CreateRecipient("email")
Dim myFBInfo As String
On Error GoTo ErrorHandler
'when and how long to look for
resolution = 60 * 24
StartDate = #9/30/2021#
myFBInfo = myRecipient.FreeBusy(StartDate, resolution, True)
For i = Len(slots) To 1 Step -1
s = CInt(Mid(slots, i, 1))
If s = olFree Or s = olTentative Then
slotDate = DateAdd("n", (i - 1) * resolution, StartDate)
Debug.Print Format(slotDate, "dd.mm.yyyy HH:MM")
End If
Next
CodePudding user response:
What about something like this:
Sub separate_digits()
mystring = "1987461765"
For i = 1 To Len(mystring)
Range("A" & i).Value = Mid(mystring, i, 1)
Next i
End Sub
Or if you prefer to use a formula, you could try:
=MID([Your original string],ROW(),1)
CodePudding user response:
Public Sub GetFreeBusyInfo()
'launch Outlook
Dim olapp As Outlook.Application
Set olapp = CreateObject("Outlook.Application")
Dim myNameSpace As Outlook.Namespace
Set myNameSpace = olapp.GetNamespace("MAPI")
Dim myRecipient As Outlook.Recipient
' who's calendar
Set myRecipient = myNameSpace.CreateRecipient("email")
Dim myFBInfo As String
On Error GoTo ErrorHandler
'when and how long to look for
resolution = 60 * 24
StartDate = #9/30/2021#
myFBInfo = myRecipient.FreeBusy(StartDate, resolution, True)
For i = Len(slots) To 1 Step -1
s = CInt(Mid(slots, i, 1))
If s = olFree Or s = olTentative Then
slotDate = DateAdd("n", (i - 1) * resolution, StartDate)
Debug.Print Format(slotDate, "dd.mm.yyyy HH:MM")
End If
Next