Randomly add a number

hartless43

New Member
Joined
Dec 28, 2022
Messages
16
Office Version
  1. 365
Platform
  1. Windows
Several months ago I ask for a way to remove a number from my Sudoku Game and got this reply:

Range("B2:J10").Replace What:=Application.WorksheetFunction.RandBetween(1, 9), Replacement:=""

This randomly picks a number from 1 - 9 and removes that number completely from the game. But in my Extreme games I don't use this because so many numbers have already been removed so is there a way to change that code above to randomly reverse the removal of a number but add a number from 1 - 9 and place it where it goes all 9 times.

I use UBI technology in my excel programming and don't know how to do this.

Thanks for a reply.,

Jerry
 

Excel Facts

Highlight Duplicates
Home, Conditional Formatting, Highlight Cells, Duplicate records, OK to add pink formatting to any duplicates in selected range.
... is there a way to change that code above to randomly reverse the removal of a number but add a number from 1 - 9 and place it where it goes all 9 times.
Can you please explain in more detail what you want to do? An example would be helpful.

Doesn't "reverse the removal" simply mean not running that line of code?

And doesn't "add a number" necessarily mean a number that's not already shown in the grid? So for example, if your set up grid shows only numbers 1 to 7, and not 8 and 9, you can change any of 1 to 6 to either 8 or 9 only. (Which won't change the difficulty of the puzzle at all.)
 
Upvote 0
StephenCrump, Thanks for your reply, but got to thinking about this. The formula above removes a number that is already in place, and if what I was requesting would not know which cell to place the random number because it does not know where it goes. This would work on the solution, but not the game generated from the solution.
 
Upvote 0
Solution

Forum statistics

Threads
1,216,500
Messages
6,131,015
Members
449,615
Latest member
Nic0la

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