Vba code to select and replace number via inputbox Help

Imran Azam

Board Regular
Joined
Mar 15, 2011
Messages
103
Hi guys

I am trying to create a macro to select and replace data on an array and display this onto a spreadsheet i am struggling to create this.

the code needs to reads the group of data below ( range cell A1- to cell f-10), into an array , and then allow the user to type a number via an inbox, this number represents the number they would like to replace from the arrey created ( range of data shown below) and, then allow user to type another number via another inbox, this number is to replace the other number in the array and displays this on the spreadsheet.

Only a number should be entered into the input box, if something other than a number is entered the inbox should reappear again.

If a number is typed in the first inbox ( the one that select number which user wants to replace) and this number isnt in array created then a message box with a warning icon ( yellow triangle with ! mark), a title “Alert” and a message saying “number not found” should appear

example data below


1​
4​
7​
10​
13​
16​
3​
6​
9​
12​
15​
18​
5​
8​
11​
14​
17​
20​
1​
10​
13​
16​
19​
22​
3​
12​
15​
18​
21​
24​
5​
14​
17​
20​
23​
26​
1​
16​
19​
22​
25​
28​
3​
10​
2​
24​
27​
30​
2​
10​
4​
2​
29​
32​
4​
12​
6​
4​
31​
34​

So the steps needed are blow
1) all the number in the group need to read into a new Array

2) Show an input box with a message ‘please entre number you wish to replace’ this should only accept numbers, if anything other than a number is typed the same input box should reappear ( when ok is clicked )until a number is typed

3) when the last step is taken by the user another inbox need to appear with message ‘please enter a new number you wish to replace selected number with’ again only number need to be entered in this input box if not number then same as step 2 will happen( input box reappear until number is entered)

4) when the last step is done by the user and the ok button is pressed the selected number is replace with the new number in the Arrey created in step 1 and also show this change on the in the group of numbers in the spreadsheet

5) If a number typed in the first inbox ( the one that select number which user wants to replace) isnt in the array entries ( array created in step 1) then a message box with a warning icon ( yellow triangle with ! mark), a title “Alert” and a message saying “number not found” should appear

hope i am making sense if not please just message

can anyone help with this?

i have also posted image of the data
 

Attachments

  • data image.PNG
    data image.PNG
    11.3 KB · Views: 11

Excel Facts

Add Bullets to Range
Select range. Press Ctrl+1. On Number tab, choose Custom. Type Alt+7 then space then @ sign (using 7 on numeric keypad)
Yet another cross post without links. Please supply the link & in future do so with having to be reminded.
 
Upvote 0
Yet another cross post without links. Please supply the link & in future do so with having to be reminded.
i posted it to the other forum about 5 min ago about to provide a link got a bit busy
 
Upvote 0

Forum statistics

Threads
1,214,911
Messages
6,122,198
Members
449,072
Latest member
DW Draft

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