Home |
Search |
Today's Posts |
#2
![]()
Posted to microsoft.public.excel.misc
|
|||
|
|||
![]()
Hi Nobbyknownowt,
I try to avoid userforms if I can get away with it. If you feel the same way you could use the following series of application.inputboxes with the input data type restricted to range. This way is very user friendly because he/she is confronted with one question at a time; also, they don't have to type in a cell address, they can input the position simply by clicking on the appropriate cell. It's also developer friendly, user forms take longer to develop. The only disadvantage is that the user has to do a bit more mouse clicking, so if RSI is a problem read no further ;-) Public Sub weight_positions() Dim rgW1 As Range 'weight a's cell position Dim rgW2 As Range 'weight b's cell position Dim rgW3 As Range 'weight c's cell position Dim rgW4 As Range 'weight d's cell position Dim Wa As Single 'I have used 10 g Dim Wb As Single 'I have used 15 g Dim Wc As Single 'I have used 25 g Dim Wd As Single 'I have used 50 g Wa = 10: Wb = 15: Wc = 25: Wd = 50 Set rgW1 = Application.InputBox(prompt:= _ "Where should the " & Wa & "g weight be?" _ & Chr(10) & "(Click Cell)", _ Type:=8) Set rgW2 = Application.InputBox(prompt:= _ "Where should the " & Wb & "g weight be?" _ & Chr(10) & "(Click Cell)", _ Type:=8) Set rgW3 = Application.InputBox(prompt:= _ "Where should the " & Wc & "g weight be?" _ & Chr(10) & "(Click Cell)", _ Type:=8) Set rgW4 = Application.InputBox(prompt:= _ "Where should the " & Wd & "g weight be?" _ & Chr(10) & "(Click Cell)", _ Type:=8) MsgBox "a at " & rgW1.Address(False, False) & Chr(10) _ & "b at " & rgW2.Address(False, False) & Chr(10) _ & "c at " & rgW3.Address(False, False) & Chr(10) _ & "d at " & rgW4.Address(False, False) & Chr(10) End Sub The msgbox on the last line is just to show you that the code works by showing the selected cell addresses. Just replace that with your code. If you also want the user to input the weight values you could include Wa = Application.InputBox(prompt:="Weight a grams=?", Type:=1) Wb = Application.InputBox(prompt:="Weight b grams=?", Type:=1) Wc = Application.InputBox(prompt:="Weight c grams=?", Type:=1) Wd = Application.InputBox(prompt:="Weight d grams=?", Type:=1) either all together so that all the weights are first entered, or position each one before its corresponding cell range input. Ken Johnson PS your spreadsheet sounds interesting. If you could send me a copy when you've finished it would be appreciated. I teach high school science so it could be useful. |
Thread Tools | Search this Thread |
Display Modes | |
|
|
![]() |
||||
Thread | Forum | |||
Linking Groups of cells between workbooks | Excel Discussion (Misc queries) | |||
checking that cells have a value before the workbook will close | Excel Worksheet Functions | |||
Lock and unlock cells conditionally depending on input in another | Excel Worksheet Functions | |||
Can I use the grouping and lock and protect cells | Excel Discussion (Misc queries) | |||
Convert data type of cells to Text,Number,Date and Time | Excel Worksheet Functions |