Reply
 
LinkBack Thread Tools Search this Thread Display Modes
  #1   Report Post  
Posted to microsoft.public.excel.programming
external usenet poster
 
Posts: 1
Default enter value line by line


Hi,

I’m just to new to this excel programming, can you teach me how t
write this program?

My program is like this,

I have one command button, every time when I press the button, it wil
store current date time to first row first column (A1), after that, i
I press again, it will store another current date time to the followin
row (A2). For this first part, I already figure out( finally ^_^’), bu
come to second part, I have some problem… I don know how to move th
data to second column. So, can you teach me how to write this part?

Thx you

Ave_av

--
ave_av
-----------------------------------------------------------------------
ave_ave's Profile: http://www.excelforum.com/member.php...fo&userid=1642
View this thread: http://www.excelforum.com/showthread.php?threadid=27795

  #2   Report Post  
Posted to microsoft.public.excel.programming
external usenet poster
 
Posts: 27,285
Default enter value line by line

At what point will it move to the second column?

Private Sub Command_button1_click()
Dim rng as Range, rng1 as Range
set rng1 = Range("A1")
if isempty(rng1) then
set rng = rng1
elseif isempty(rng1(2)) then
set rng = rng1(2)
else
set rng = rng1.End(xldown)(2)
end if
rng.Value = now
rng.format = "mm/dd/yyyy hh:mm:ss")
rng.EntireColumn.Autofit
End Sub

--
Regards,
Tom Ogilvy

"ave_ave" wrote in message
...

Hi,

I'm just to new to this excel programming, can you teach me how to
write this program?

My program is like this,

I have one command button, every time when I press the button, it will
store current date time to first row first column (A1), after that, if
I press again, it will store another current date time to the following
row (A2). For this first part, I already figure out( finally ^_^'), but
come to second part, I have some problem. I don know how to move the
data to second column. So, can you teach me how to write this part?

Thx you

Ave_ave


--
ave_ave
------------------------------------------------------------------------
ave_ave's Profile:

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



  #3   Report Post  
Posted to microsoft.public.excel.programming
external usenet poster
 
Posts: 1,758
Default enter value line by line

How do you know when to start on the second column?

Maybe if you've already entered values in the first 10 rows?

This may be a little overkill, since it checks a few things that may not need to
be checked.

Option Explicit
Sub testme()

Dim myCell As Range
Dim iCol As Long

Set myCell = Nothing
With ActiveSheet
For iCol = 1 To .Columns.Count '256
Set myCell = .Cells(.Rows.Count, iCol).End(xlUp)
If IsEmpty(myCell) Then
'do nothing
Else
Set myCell = myCell.Offset(1, 0)
End If
If myCell.Row < 11 Then
Exit For
Else
'keep going
End If
Next iCol
End With

If myCell Is Nothing Then
MsgBox "ran out of columns!!!"
Else
With myCell
.Value = Date
.NumberFormat = "mm/dd/yyyy"
End With
End If

End Sub


ave_ave wrote:

Hi,

I’m just to new to this excel programming, can you teach me how to
write this program?

My program is like this,

I have one command button, every time when I press the button, it will
store current date time to first row first column (A1), after that, if
I press again, it will store another current date time to the following
row (A2). For this first part, I already figure out( finally ^_^’), but
come to second part, I have some problem… I don know how to move the
data to second column. So, can you teach me how to write this part?

Thx you

Ave_ave

--
ave_ave
------------------------------------------------------------------------
ave_ave's Profile: http://www.excelforum.com/member.php...o&userid=16425
View this thread: http://www.excelforum.com/showthread...hreadid=277951


--

Dave Peterson
Reply
Thread Tools Search this Thread
Search this Thread:

Advanced Search
Display Modes

Posting Rules

Smilies are On
[IMG] code is On
HTML code is Off
Trackbacks are On
Pingbacks are On
Refbacks are On


Similar Threads
Thread Thread Starter Forum Replies Last Post
Alt-Enter Line Breaks Keven Denen Excel Discussion (Misc queries) 2 October 7th 09 04:37 PM
How to convert a dotted line to a solid line in a line graph Sharlz Charts and Charting in Excel 1 January 14th 09 04:51 AM
enter does 1 line space- scanner does 2 line space need 1 line lockboat New Users to Excel 0 September 6th 08 02:20 PM
WHY WON'T MY ENTER KEY RETURN TO THE NEXT LINE? SUEBEEDOO Excel Discussion (Misc queries) 1 June 28th 06 09:29 PM
WHY WON'T MY ENTER KEY RETURN TO THE NEXT LINE? SUEBEEDOO Excel Discussion (Misc queries) 2 June 28th 06 07:34 PM


All times are GMT +1. The time now is 03:36 PM.

Powered by vBulletin® Copyright ©2000 - 2025, Jelsoft Enterprises Ltd.
Copyright ©2004-2025 ExcelBanter.
The comments are property of their posters.
 

About Us

"It's about Microsoft Excel"