VBA so it returns 2 columns of data not 4

NZAS

Board Regular
Joined
Oct 18, 2012
Messages
117
Office Version
  1. 365
  2. 2019
Platform
  1. Windows
The vba codes (TeeDrawPlayers) below returns 4 columns of data and the second one (TeeDrawCarts) I want it to return 2 columns of data how can I update the second one to do this
Cheers
NZAS


Sub TeeDrawPlayers()
Range("A3:D40").ClearContents
lo = Range("A2") ' low
hi = Range("B2") 'high
rg = hi - lo
r = 3
c = 1
For p = lo To hi
10 x = WorksheetFunction.RandBetween(lo, hi)
If WorksheetFunction.CountIf(Range("A3:D40"), x) >= 1 Then GoTo 10 'find another number
Cells(r, c) = x
c = c + 1
If c = 5 Then
r = r + 1
c = 1
End If
Next p
End Sub


Sub TeeDrawCarts()
Range("A46:D60").ClearContents
lo = Range("A45") ' low
hi = Range("B45") 'high
rg = hi - lo
r = 46
c = 1
For p = lo To hi
10 x = WorksheetFunction.RandBetween(lo, hi)
If WorksheetFunction.CountIf(Range("A46:B60"), x) >= 1 Then GoTo 10 'find another number
Cells(r, c) = x
c = c + 1
If c = 3 Then
r = r + 1
c = 1
End If
Next p
End Sub
 

Excel Facts

Excel Joke
Why can't spreadsheets drive cars? They crash too often!
The vba codes (TeeDrawPlayers) below returns 4 columns of data and the second one (TeeDrawCarts) I want it to return 2 columns of data how can I update the second one to do this
Cheers
NZAS
The first code you posted returns data in 4 columns.
The second code returns data in 2 columns.

What changes do you want?
 
Upvote 0
Solution
Sorry all wrong question will put in he wright question on a vlookup
 
Upvote 0

Forum statistics

Threads
1,224,823
Messages
6,181,170
Members
453,021
Latest member
Justyna P

We've detected that you are using an adblocker.

We have a great community of people providing Excel help here, but the hosting costs are enormous. You can help keep this site running by allowing ads on MrExcel.com.
Allow Ads at MrExcel

Which adblocker are you using?

Disable AdBlock

Follow these easy steps to disable AdBlock

1)Click on the icon in the browser’s toolbar.
2)Click on the icon in the browser’s toolbar.
2)Click on the "Pause on this site" option.
Go back

Disable AdBlock Plus

Follow these easy steps to disable AdBlock Plus

1)Click on the icon in the browser’s toolbar.
2)Click on the toggle to disable it for "mrexcel.com".
Go back

Disable uBlock Origin

Follow these easy steps to disable uBlock Origin

1)Click on the icon in the browser’s toolbar.
2)Click on the "Power" button.
3)Click on the "Refresh" button.
Go back

Disable uBlock

Follow these easy steps to disable uBlock

1)Click on the icon in the browser’s toolbar.
2)Click on the "Power" button.
3)Click on the "Refresh" button.
Go back
Back
Top