Reply
 
LinkBack Thread Tools Search this Thread Display Modes
  #1   Report Post  
Posted to microsoft.public.excel.programming
Pam Pam is offline
external usenet poster
 
Posts: 128
Default make cell active in beginning of macro

I am running the following code which works great for inserting a date into a
cell with a calendar, but it only works great if they are in the right active
cell when they click the macro. I need to reduce errors by making the active
cell b1 when they start the macro, do that it will check the date in that
cell, and return the date in that cell.
I'm lost., any help would be appreciated.
Thanks


Private Sub UserForm_Initialize()

If IsDate(ActiveCell.Value) Then
Calendar1.Value = DateValue(ActiveCell.Value)
Else
Calendar1.Value = Date

Range("B1").Value = Date

End If
End Sub
  #2   Report Post  
Posted to microsoft.public.excel.programming
N10 N10 is offline
external usenet poster
 
Posts: 141
Default make cell active in beginning of macro

Pam


Private Sub UserForm_Initialize()

Range("b1").select

If IsDate(ActiveCell.Value) Then
Calendar1.Value = DateValue(ActiveCell.Value)
Else
Calendar1.Value = Date

Range("B1").Value = Date

End If


Best N10

End Sub
"Pam" wrote in message
...
I am running the following code which works great for inserting a date into
a
cell with a calendar, but it only works great if they are in the right
active
cell when they click the macro. I need to reduce errors by making the
active
cell b1 when they start the macro, do that it will check the date in that
cell, and return the date in that cell.
I'm lost., any help would be appreciated.
Thanks


Private Sub UserForm_Initialize()

If IsDate(ActiveCell.Value) Then
Calendar1.Value = DateValue(ActiveCell.Value)
Else
Calendar1.Value = Date

Range("B1").Value = Date

End If
End Sub



  #3   Report Post  
Posted to microsoft.public.excel.programming
external usenet poster
 
Posts: 9,101
Default make cell active in beginning of macro

Private Sub UserForm_Initialize()

If IsDate(Range("B1").Value) Then
Calendar1.Value = DateValue(Range("B1").Value)
Else
Calendar1.Value = Date

Range("B1").Value = Date

End If
End Sub

"Pam" wrote:

I am running the following code which works great for inserting a date into a
cell with a calendar, but it only works great if they are in the right active
cell when they click the macro. I need to reduce errors by making the active
cell b1 when they start the macro, do that it will check the date in that
cell, and return the date in that cell.
I'm lost., any help would be appreciated.
Thanks


Private Sub UserForm_Initialize()

If IsDate(ActiveCell.Value) Then
Calendar1.Value = DateValue(ActiveCell.Value)
Else
Calendar1.Value = Date

Range("B1").Value = Date

End If
End Sub

  #4   Report Post  
Posted to microsoft.public.excel.programming
Pam Pam is offline
external usenet poster
 
Posts: 128
Default make cell active in beginning of macro

Thank you, I knew it was simple

"N10" wrote:

Pam


Private Sub UserForm_Initialize()

Range("b1").select

If IsDate(ActiveCell.Value) Then
Calendar1.Value = DateValue(ActiveCell.Value)
Else
Calendar1.Value = Date

Range("B1").Value = Date

End If


Best N10

End Sub
"Pam" wrote in message
...
I am running the following code which works great for inserting a date into
a
cell with a calendar, but it only works great if they are in the right
active
cell when they click the macro. I need to reduce errors by making the
active
cell b1 when they start the macro, do that it will check the date in that
cell, and return the date in that cell.
I'm lost., any help would be appreciated.
Thanks


Private Sub UserForm_Initialize()

If IsDate(ActiveCell.Value) Then
Calendar1.Value = DateValue(ActiveCell.Value)
Else
Calendar1.Value = Date

Range("B1").Value = Date

End If
End Sub




  #5   Report Post  
Posted to microsoft.public.excel.programming
Pam Pam is offline
external usenet poster
 
Posts: 128
Default make cell active in beginning of macro

Joel,
When I tried this it put the result in the cell I was in, although it seems
to be comparing the original cell?

"Joel" wrote:

Private Sub UserForm_Initialize()

If IsDate(Range("B1").Value) Then
Calendar1.Value = DateValue(Range("B1").Value)
Else
Calendar1.Value = Date

Range("B1").Value = Date

End If
End Sub

"Pam" wrote:

I am running the following code which works great for inserting a date into a
cell with a calendar, but it only works great if they are in the right active
cell when they click the macro. I need to reduce errors by making the active
cell b1 when they start the macro, do that it will check the date in that
cell, and return the date in that cell.
I'm lost., any help would be appreciated.
Thanks


Private Sub UserForm_Initialize()

If IsDate(ActiveCell.Value) Then
Calendar1.Value = DateValue(ActiveCell.Value)
Else
Calendar1.Value = Date

Range("B1").Value = Date

End If
End Sub



  #6   Report Post  
Posted to microsoft.public.excel.programming
external usenet poster
 
Posts: 9,101
Default make cell active in beginning of macro

Pam: The code you posted is only the initialize function when the userform is
opened. Check to see if the active cell gets changed before you enter
anything into the userform. If the active cell doesn't get changed during
the initialization then there is other code that is writing to the active
cell that you didn't post.

The code you posted should only change two items. Range "B1" and the
initial vbalue in Calandar1.value which I assume is some box on the form
(textbox, listbox, combobox).

"Pam" wrote:

Joel,
When I tried this it put the result in the cell I was in, although it seems
to be comparing the original cell?

"Joel" wrote:

Private Sub UserForm_Initialize()

If IsDate(Range("B1").Value) Then
Calendar1.Value = DateValue(Range("B1").Value)
Else
Calendar1.Value = Date

Range("B1").Value = Date

End If
End Sub

"Pam" wrote:

I am running the following code which works great for inserting a date into a
cell with a calendar, but it only works great if they are in the right active
cell when they click the macro. I need to reduce errors by making the active
cell b1 when they start the macro, do that it will check the date in that
cell, and return the date in that cell.
I'm lost., any help would be appreciated.
Thanks


Private Sub UserForm_Initialize()

If IsDate(ActiveCell.Value) Then
Calendar1.Value = DateValue(ActiveCell.Value)
Else
Calendar1.Value = Date

Range("B1").Value = Date

End If
End Sub

  #7   Report Post  
Posted to microsoft.public.excel.programming
Pam Pam is offline
external usenet poster
 
Posts: 128
Default make cell active in beginning of macro

Okay, the B1 is the cell that I want it to check to see if there's a date,
and change that if there is not a date, does that make sense?
If there is a date, I want it to leave it alone, if there is not, I want it
to default to today's date, I probably have the code wrong, but this will
work for now.
Thanks

"Joel" wrote:

Pam: The code you posted is only the initialize function when the userform is
opened. Check to see if the active cell gets changed before you enter
anything into the userform. If the active cell doesn't get changed during
the initialization then there is other code that is writing to the active
cell that you didn't post.

The code you posted should only change two items. Range "B1" and the
initial vbalue in Calandar1.value which I assume is some box on the form
(textbox, listbox, combobox).

"Pam" wrote:

Joel,
When I tried this it put the result in the cell I was in, although it seems
to be comparing the original cell?

"Joel" wrote:

Private Sub UserForm_Initialize()

If IsDate(Range("B1").Value) Then
Calendar1.Value = DateValue(Range("B1").Value)
Else
Calendar1.Value = Date

Range("B1").Value = Date

End If
End Sub

"Pam" wrote:

I am running the following code which works great for inserting a date into a
cell with a calendar, but it only works great if they are in the right active
cell when they click the macro. I need to reduce errors by making the active
cell b1 when they start the macro, do that it will check the date in that
cell, and return the date in that cell.
I'm lost., any help would be appreciated.
Thanks


Private Sub UserForm_Initialize()

If IsDate(ActiveCell.Value) Then
Calendar1.Value = DateValue(ActiveCell.Value)
Else
Calendar1.Value = Date

Range("B1").Value = Date

End If
End Sub

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
macro to find cell content in sheets and make sheet active Nigel Excel Discussion (Misc queries) 4 June 26th 14 02:38 PM
use current cell address as beginning of macro mohavv Excel Discussion (Misc queries) 2 April 18th 08 03:52 PM
Make the next cell active [email protected] Excel Programming 3 March 28th 06 06:56 PM
Make a Word event macro fire in active document [email protected] Excel Programming 2 March 27th 06 01:00 PM
Make a particular cell the active one Newbie Excel Programming 3 April 14th 04 04:52 PM


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

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

About Us

"It's about Microsoft Excel"