-
Jul 21st, 2020, 10:30 AM
#1
Thread Starter
New Member
[RESOLVED] Excel VBA - Auto find and fill blank cells with random yes or no
I need to fill blank cells in a specific column of a table whihc is connected to an online data source.
the code i currently have is:
Code:
Dim i As Long
With Sheets("Live Share Data")
Range("a1").End(xlDown).Select
Last_row = ActiveCell.Row
For i = 2 To Last_row
If Worksheets("Live Share Data").Cells(i, 11).Value = "" Then
Worksheets("Live Share Data").Cells(i, 11).Value = Choose(RandBetween(1, 2), "Yes", "No")
Next
End If
End Sub
the code currently breaks when it hits "Choose" any ideas where i have gone wrong here?
I have posted this on mrexcel forum but after little interest i have asked them to delete the post there. if i get any updates i will update in both locations.
-
Jul 21st, 2020, 04:27 PM
#2
Re: Excel VBA - Auto find and fill blank cells with random yes or no
i tested this to work ok
Code:
Dim i As Long
Randomize
With Sheets(1)
Last_row = .Range("a1").End(xlDown).row
For i = 2 To Last_row
If .Cells(i, 1).Value = "" Then
.Cells(i, 1).Value = Choose(Int((2 * Rnd) + 1), "Yes", "No")
End If
Next
End With
randbetween must be some custom function that you don't have
i do my best to test code works before i post it, but sometimes am unable to do so for some reason, and usually say so if this is the case.
Note code snippets posted are just that and do not include error handling that is required in real world applications, but avoid On Error Resume Next
dim all variables as required as often i have done so elsewhere in my code but only posted the relevant part
come back and mark your original post as resolved if your problem is fixed
pete
-
Jul 22nd, 2020, 02:24 AM
#3
Thread Starter
New Member
Re: Excel VBA - Auto find and fill blank cells with random yes or no
westconn1, thank you very much. nice and eligant solution
Posting Permissions
- You may not post new threads
- You may not post replies
- You may not post attachments
- You may not edit your posts
-
Forum Rules
|
Click Here to Expand Forum to Full Width
|