Paste MyInput in to a cell

roka001

Board Regular
Joined
Aug 6, 2007
Messages
72
Hi all!

After going through every thread with the word input and inputbox I have no choise but to write a questing.

This is what I want to do:
I'm going to creat a logsheet where the user types his or her user namn.
Code:
Sub log()

myinput = InputBox("Type your user name")
myinput2 = Now
MsgBox myinput & (" saved and it was logged:") & myinput2
Call find_blank_cell
End Sub

So far so good...
What I now want to do is to get the value from input and input2 to the next blank cell.
This is how I did that.
Code:
Sub find_blank_cell()
If Not ActiveCell = "" Then
ActiveCell.Offset(1, 0).Select
Call find_insert_log_space
Else
Call insert_log
End If
End Sub
You could probaly get it to work in a different way... I'm open for suggesions. =)

Now to my problem!

I can't get the inputs to be pasted in to the cells.
I have looked and looked everywhere and cant find a hint or a clue to what to do.

Something like this maybe? This is not the correct code but I dont know how to explain it.
Code:
Sub insert_log()
Myinput2.paste to Activecell 'The date first
ActiveCell.Offset(0, 1).Select
Myinput.paste to Activecell 'Then the user namn
End sub


I'm clueless...
 

Excel Facts

Create a chart in one keystroke
Select the data and press Alt+F1 to insert a default chart. You can change the default chart to any chart type
Hi and welcome to the board! :)

This line will put the value of "myinput2" in the next empty cell in column A:
Code:
Cells(Cells(Rows.Count, 1).End(xlUp).Row + 1, 1) = myinput2
Hope that helps!
 
Upvote 0
Hi,

Try this:

Code:
Sub log()

Dim myInput As String, myInput2 As Long, lastRow As Long


myInput = Environ("username")
myInput2 = Now

lastRow = Range("A65536").End(xlUp).Row

Cells(lastRow + 1, 1).Value = myInput
Cells(lastRow + 1, 2).Value = myInput2

MsgBox myInput & (" saved and it was logged:") & myInput2

End Sub

Hope it helps,

Dom
 
Upvote 0
That one worked fine.. thx!

How does the code look for just getting the value from myinput to what ever cell?

Course
Code:
Cells = myinput
just messes things up. Almost killed my comupter =)
 
Upvote 0
Hi,

Try this:

Code:
Sub log()

Dim myInput As String, myInput2 As Long, lastRow As Long


myInput = Environ("username")
myInput2 = Now

lastRow = Range("A65536").End(xlUp).Row

Cells(lastRow + 1, 1).Value = myInput
Cells(lastRow + 1, 2).Value = myInput2

MsgBox myInput & (" saved and it was logged:") & myInput2

End Sub

Hope it helps,

Dom

Wow... that was what I wanted all along!! Sweet.. thanx alot!


Still wanna know how to input a value from an inputbox to a cell.
 
Upvote 0
The reason that will mess things up is because "Cells" represents every cell on the worksheet. You can refer to an individual cell in a number of ways. For example, to put "myinput" into cell A1 you could use:
Range("A1") = myinput
or
Cells(1,1) = myinput
or
[A1] = myinput
 
Upvote 0
---->Domski

Why is the date one day ahead?
its 2007-08-06
when running the macro it displays 2007-08-07??

Freaky... =)
 
Upvote 0
The reason that will mess things up is because "Cells" represents every cell on the worksheet. You can refer to an individual cell in a number of ways. For example, to put "myinput" into cell A1 you could use:
Range("A1") = myinput
or
Cells(1,1) = myinput
or
[A1] = myinput

Does not that only work when I know witch cell I want to paste the input in?

I was thinking more along with something like this:

Using
ActiveCell.Offset(1, 0).Select
To guide the macro to what ever statements there is.
and when one is found it drops on row and inserts the input there.
 
Upvote 0
Sorry, should have spotted that.

Try:

Code:
Sub log()

Dim myInput As String, myInput2 As Long, lastRow As Long


myInput = Environ("username")
myInput2 = Date

lastRow = Range("A65536").End(xlUp).Row

Cells(lastRow + 1, 1).Value = myInput
Cells(lastRow + 1, 2).Value = myInput2

MsgBox myInput & (" saved and it was logged:") & Format(Date, "Long Date")

End Sub

Dom
 
Upvote 0
You can again use various methods of programmatically finding the cell you want to use and incorporating variables into the cell reference. However, with the exampl you have given then you would use something like:
ActiveCell.Offset(1,0).Value = myinput
 
Upvote 0

Forum statistics

Threads
1,214,944
Messages
6,122,392
Members
449,081
Latest member
JAMES KECULAH

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