ExcelBanter

ExcelBanter (https://www.excelbanter.com/)
-   Excel Programming (https://www.excelbanter.com/excel-programming/)
-   -   Help with inputbox cel reference (https://www.excelbanter.com/excel-programming/336153-help-inputbox-cel-reference.html)

Janet H[_2_]

Help with inputbox cel reference
 
The input box routine below does exactly what I want it to - but only on the
first line. I want to modify it so it works on every row. The cell references
of b, j & K remain the same but the line reference varies. How do I set it up
so it knows what line it's on?

I'm a newbie so some extra explanation is helpful. Thanks!

ActiveSheet.Unprotect
Range("b63").Select
ActiveCell = "x"
mynum = Application.InputBox("Payment including Adj")
Range("j63").Value = mynum
mynum = Application.InputBox("Enter total overpayment remaining")
Range("k63").Value = mynum
ActiveSheet.Protect

cory

Help with inputbox cel reference
 
Janet,

Some clarification may be needed, namely what you mean by wanting the macro
to work on every row. I will assume that you want to be able to run the macro
on whatever line you are currently on. If this is the case, you won't need
the Range("B63").Select command.

To find out the current line (row) that the macro is on use the following:

ActiveCell.Row

You can also simplify your code by assigning the InputBox statements
directly to a cell value rather than first assigning it to a variable and
then assigning that variable to the cell. Putting all of this together you
end up with the following:

ActiveSheet.Unprotect
Range("B" & ActiveCell.Row) = "x"
Range("J" & ActiveCell.Row) = Application.InputBox("Payment including
Adj")
Range("K" & ActiveCell.Row) = Application.InputBox("Enter total
overpayment remaining")
ActiveSheet.Protect

Hope this helps.
-Cory

Tom Ogilvy

Help with inputbox cel reference
 
Dim cell as Range
ActiveSheet.Unprotect
for each cell in Range("B63:B50")
cell.Select
ActiveCell = "x"
mynum = Application.InputBox("Payment including Adj")
Cells(cell.row,"J").Value = mynum
mynum = Application.InputBox("Enter total overpayment remaining")
cells(cell.row,"k").Value = mynum
Next
ActiveSheet.Protect

--
Regards,
Tom Ogilvy

"Janet H" wrote in message
...
The input box routine below does exactly what I want it to - but only on

the
first line. I want to modify it so it works on every row. The cell

references
of b, j & K remain the same but the line reference varies. How do I set it

up
so it knows what line it's on?

I'm a newbie so some extra explanation is helpful. Thanks!

ActiveSheet.Unprotect
Range("b63").Select
ActiveCell = "x"
mynum = Application.InputBox("Payment including Adj")
Range("j63").Value = mynum
mynum = Application.InputBox("Enter total overpayment remaining")
Range("k63").Value = mynum
ActiveSheet.Protect




Janet H[_2_]

Help with inputbox cel reference
 
Awesome! Thanks

"Cory" wrote:

Janet,

Some clarification may be needed, namely what you mean by wanting the macro
to work on every row. I will assume that you want to be able to run the macro
on whatever line you are currently on. If this is the case, you won't need
the Range("B63").Select command.

To find out the current line (row) that the macro is on use the following:

ActiveCell.Row

You can also simplify your code by assigning the InputBox statements
directly to a cell value rather than first assigning it to a variable and
then assigning that variable to the cell. Putting all of this together you
end up with the following:

ActiveSheet.Unprotect
Range("B" & ActiveCell.Row) = "x"
Range("J" & ActiveCell.Row) = Application.InputBox("Payment including
Adj")
Range("K" & ActiveCell.Row) = Application.InputBox("Enter total
overpayment remaining")
ActiveSheet.Protect

Hope this helps.
-Cory



All times are GMT +1. The time now is 05:29 PM.

Powered by vBulletin® Copyright ©2000 - 2025, Jelsoft Enterprises Ltd.
ExcelBanter.com