ExcelBanter

ExcelBanter (https://www.excelbanter.com/)
-   Excel Discussion (Misc queries) (https://www.excelbanter.com/excel-discussion-misc-queries/)
-   -   Macro (https://www.excelbanter.com/excel-discussion-misc-queries/179446-macro.html)

Cedric

Macro
 
I recently found the macro listed below. If I wanted the macro to run until
I enter XXX how would I go about that. I would want a line between each date.


Option Explicit

Private Sub Workbook_Open()

Dim vDate As String

vDate = InputBox("Please type in a date")

Worksheets("Sheet1").Range("A1") = vDate

End Sub


Thanks in advance


Dave Peterson

Macro
 
Option Explicit
Private Sub Workbook_Open()

Dim vDate As String
Dim DestCell As Range

Set DestCell = Worksheets("Sheet1").Range("A1")

Do
vDate = InputBox("Please type in a date")
If LCase(vDate) = LCase("xxx") Then
Exit Do
Else
DestCell = vDate
Set DestCell = DestCell.Offset(2, 0)
End If
Loop

End Sub


Cedric wrote:

I recently found the macro listed below. If I wanted the macro to run until
I enter XXX how would I go about that. I would want a line between each date.

Option Explicit

Private Sub Workbook_Open()

Dim vDate As String

vDate = InputBox("Please type in a date")

Worksheets("Sheet1").Range("A1") = vDate

End Sub

Thanks in advance


--

Dave Peterson

Gord Dibben

Macro
 
The macro would drop dates in column A so fast you would be full before you ever
typed your XXX

How about two inputboxes?

One for the date and one for the number of dates down column A

Private Sub Workbook_Open()
Dim rng As Range
Dim I As Integer
Dim vDate As Date
Dim numtimes As Integer
With Sheets("Sheet1")
vDate = InputBox("Please type in a date")
numtimes = InputBox("How far to increment? Enter a number")
Set rng = Range("A1")
rng.Value = vDate
For I = 1 To numtimes Step 1
rng.Offset(I, 0).Value = rng.Offset(I - 1, 0).Value + 1
Next I
End With
End Sub


Gord Dibben MS Excel MVP

On Mon, 10 Mar 2008 12:18:00 -0700, Cedric
wrote:

I recently found the macro listed below. If I wanted the macro to run until
I enter XXX how would I go about that. I would want a line between each date.


Option Explicit

Private Sub Workbook_Open()

Dim vDate As String

vDate = InputBox("Please type in a date")

Worksheets("Sheet1").Range("A1") = vDate

End Sub


Thanks in advance




All times are GMT +1. The time now is 01:21 PM.

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