ExcelBanter

ExcelBanter (https://www.excelbanter.com/)
-   Excel Programming (https://www.excelbanter.com/excel-programming/)
-   -   Adding input to macro (https://www.excelbanter.com/excel-programming/344768-adding-input-macro.html)

cappuccine[_5_]

Adding input to macro
 

I posted this yesterday but didn't get an answer so here it is again:

ok just to restate my next question. I am using this code for the
current date:

Sub placeDate()
Dim rng as Range
set rng = cells(rows.count,"A").End(xlup)
if not isempty(rng) then
' check that it isn't already there
if rng.value = date then exit sub
' it isn't the current date, so place today's
' date in the next cell
set rng = rng.offset(1,0)
end if

rng.Value = Date
End Sub


Now I want to ask the user what value to input into column E of the
same row as the current date. Can I add that easily in now? And how?


--
cappuccine
------------------------------------------------------------------------
cappuccine's Profile: http://www.excelforum.com/member.php...o&userid=28242
View this thread: http://www.excelforum.com/showthread...hreadid=482267


Andrew Taylor

Adding input to macro
 
You can use the InputBox() function to get input from the user.

cappuccine wrote:
I posted this yesterday but didn't get an answer so here it is again:

ok just to restate my next question. I am using this code for the
current date:

Sub placeDate()
Dim rng as Range
set rng = cells(rows.count,"A").End(xlup)
if not isempty(rng) then
' check that it isn't already there
if rng.value = date then exit sub
' it isn't the current date, so place today's
' date in the next cell
set rng = rng.offset(1,0)
end if

rng.Value = Date
End Sub


Now I want to ask the user what value to input into column E of the
same row as the current date. Can I add that easily in now? And how?


--
cappuccine
------------------------------------------------------------------------
cappuccine's Profile: http://www.excelforum.com/member.php...o&userid=28242
View this thread: http://www.excelforum.com/showthread...hreadid=482267



cappuccine[_6_]

Adding input to macro
 

ok how do I use that? And how do I input that value into column E in the
same row that the previous macro found as an open space to put the date
in?


--
cappuccine
------------------------------------------------------------------------
cappuccine's Profile: http://www.excelforum.com/member.php...o&userid=28242
View this thread: http://www.excelforum.com/showthread...hreadid=482267


Bob Phillips[_6_]

Adding input to macro
 
rng.Value = Date
rng.offset(0,4).value = InputBox("Supply value please")
End Sub


--

HTH

RP
(remove nothere from the email address if mailing direct)


"cappuccine" wrote
in message ...

I posted this yesterday but didn't get an answer so here it is again:

ok just to restate my next question. I am using this code for the
current date:

Sub placeDate()
Dim rng as Range
set rng = cells(rows.count,"A").End(xlup)
if not isempty(rng) then
' check that it isn't already there
if rng.value = date then exit sub
' it isn't the current date, so place today's
' date in the next cell
set rng = rng.offset(1,0)
end if

rng.Value = Date
End Sub


Now I want to ask the user what value to input into column E of the
same row as the current date. Can I add that easily in now? And how?


--
cappuccine
------------------------------------------------------------------------
cappuccine's Profile:

http://www.excelforum.com/member.php...o&userid=28242
View this thread: http://www.excelforum.com/showthread...hreadid=482267




cappuccine[_7_]

Adding input to macro
 

awesome.. ok, another question. Now that I have the value from the input
box, I want to repeat the code again to do the same thing on a different
sheet. I changed rng to rng1 so I don't get a duplicate error. How do I
use the value from the input box again without having to ask for it
again?


--
cappuccine
------------------------------------------------------------------------
cappuccine's Profile: http://www.excelforum.com/member.php...o&userid=28242
View this thread: http://www.excelforum.com/showthread...hreadid=482267


Bob Phillips[_6_]

Adding input to macro
 
rng.Value = Date
myVal = InputBox("Supply value please")
rng.offset(0,4).value = myVal
' the other code
rng1.offset(0,4).value = myVal
End Sub



--

HTH

RP
(remove nothere from the email address if mailing direct)


"cappuccine" wrote
in message ...

awesome.. ok, another question. Now that I have the value from the input
box, I want to repeat the code again to do the same thing on a different
sheet. I changed rng to rng1 so I don't get a duplicate error. How do I
use the value from the input box again without having to ask for it
again?


--
cappuccine
------------------------------------------------------------------------
cappuccine's Profile:

http://www.excelforum.com/member.php...o&userid=28242
View this thread: http://www.excelforum.com/showthread...hreadid=482267





All times are GMT +1. The time now is 03:50 AM.

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