Reply
 
LinkBack Thread Tools Search this Thread Display Modes
  #1   Report Post  
Posted to microsoft.public.excel.programming
external usenet poster
 
Posts: 86
Default Make 1 UserForm macro target different predefined cells

Hello, Programmers!

I created a UserForm calendar whose default behavior is to put the date you
select in the active cell.

I made a calendar icon, assigned it the OpenCalendar macro, made copies and
positioned the icons approximately in cells C4, C6, C25 and C27.

The code behind the UserForm is this:

Private Sub Calendar1_Click()
ActiveCell.Value = Calendar1.Value
Unload Me
End Sub

I need each calendar to populate B4, B6, B25 and B27, respectively.

So I changed ActiveCell.Value to Range("B4").Value, but off course that
means all 4 icons now populate B4. I figured you could look at the cell the
icon was in and move 1 to the left, but the icon has no address. Or does it?

If someone could enlighten me on how to make each calendar put a date in its
respective B cell, I would appreciate it greatly.

I thank you for your time.

Arlen
  #2   Report Post  
Posted to microsoft.public.excel.programming
external usenet poster
 
Posts: 35,218
Default Make 1 UserForm macro target different predefined cells

So your macro that shows the userform (OpenCalendar macro) is assigned to each
of the 4 pictures.

If that's the case, you could do this in a General module (probably were the
OpenCalendar subroutine is:

Option Explicit
Public PictCell as range
Sub OpenCalendar()
set pictcell = activesheet.pictures(application.caller).topleftce ll
CalUserForm.show 'userform1????
set pictcell = nothing
End sub

===
in the userform module.
Private Sub Calendar1_Click()
if PictCell is nothing then
'something went really bad!
'msgbox "oh, oh!"
else
pictcell.offset(0,1).Value = Calendar1.Value
end if
Unload Me
End Sub

Arlen wrote:

Hello, Programmers!

I created a UserForm calendar whose default behavior is to put the date you
select in the active cell.

I made a calendar icon, assigned it the OpenCalendar macro, made copies and
positioned the icons approximately in cells C4, C6, C25 and C27.

The code behind the UserForm is this:

Private Sub Calendar1_Click()
ActiveCell.Value = Calendar1.Value
Unload Me
End Sub

I need each calendar to populate B4, B6, B25 and B27, respectively.

So I changed ActiveCell.Value to Range("B4").Value, but off course that
means all 4 icons now populate B4. I figured you could look at the cell the
icon was in and move 1 to the left, but the icon has no address. Or does it?

If someone could enlighten me on how to make each calendar put a date in its
respective B cell, I would appreciate it greatly.

I thank you for your time.

Arlen


--

Dave Peterson
  #3   Report Post  
Posted to microsoft.public.excel.programming
external usenet poster
 
Posts: 86
Default Make 1 UserForm macro target different predefined cells

Dave,

It's days later and I just tried out your code. It works perfectly.

Thank you sir.

Have a great one!

Arlen

"Dave Peterson" wrote:

So your macro that shows the userform (OpenCalendar macro) is assigned to each
of the 4 pictures.

If that's the case, you could do this in a General module (probably were the
OpenCalendar subroutine is:

Option Explicit
Public PictCell as range
Sub OpenCalendar()
set pictcell = activesheet.pictures(application.caller).topleftce ll
CalUserForm.show 'userform1????
set pictcell = nothing
End sub

===
in the userform module.
Private Sub Calendar1_Click()
if PictCell is nothing then
'something went really bad!
'msgbox "oh, oh!"
else
pictcell.offset(0,1).Value = Calendar1.Value
end if
Unload Me
End Sub

Arlen wrote:

Hello, Programmers!

I created a UserForm calendar whose default behavior is to put the date you
select in the active cell.

I made a calendar icon, assigned it the OpenCalendar macro, made copies and
positioned the icons approximately in cells C4, C6, C25 and C27.

The code behind the UserForm is this:

Private Sub Calendar1_Click()
ActiveCell.Value = Calendar1.Value
Unload Me
End Sub

I need each calendar to populate B4, B6, B25 and B27, respectively.

So I changed ActiveCell.Value to Range("B4").Value, but off course that
means all 4 icons now populate B4. I figured you could look at the cell the
icon was in and move 1 to the left, but the icon has no address. Or does it?

If someone could enlighten me on how to make each calendar put a date in its
respective B cell, I would appreciate it greatly.

I thank you for your time.

Arlen


--

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
Combine 2 cells to match a predefined name? tgardiner Excel Discussion (Misc queries) 7 October 25th 08 04:30 AM
How do I make hyperlink target scroll to the top-left of spreadshe Lori W. Excel Discussion (Misc queries) 5 January 11th 08 08:21 PM
How to replace cells by (predefined) ranges firsttimer Excel Programming 1 May 31st 07 10:43 AM
Calling a Userform from a Predefined Variable [email protected] Excel Worksheet Functions 0 April 21st 07 03:44 PM
how do i make a macro that will select all those cells that are empty VB Script for Excel Excel Programming 2 April 27th 06 09:06 AM


All times are GMT +1. The time now is 05:21 AM.

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"