View Single Post
  #4   Report Post  
Posted to microsoft.public.excel.worksheet.functions
Dave Peterson Dave Peterson is offline
external usenet poster
 
Posts: 35,218
Default End if without Block If

I'd try:

Private Sub Worksheet_SelectionChange(ByVal Target As Excel.Range)

Dim ans As Long

If Target.Address = me.Range("p1").Address Then
ans = MsgBox("Are you finished inputing Daily Info?", vbYesNo)
If ans = vbNo Then
me.parent.SaveAs Filename:=me.Range("A1").Value & _
Format(me.parent.Worksheets("Daily") _
.Range("ax1").Value, "yyyy-mm-dd") & ".xls"
End if
End If
End Sub

Personally, I avoid those if/then one liners. I like the block if/then/else
structures.

And you sure you want to check to see if the user hit the No button?

me is the worksheet with the code.
me.parent is the workbook that owns the worksheet with the code. I like that
better than using Activeworkbook.



"Carrie_Loos via OfficeKB.com" wrote:

You know, I started off that way but then the macro just doesn't respond, I
can't even get the cursur to move with striking the enter key. So I thought
it was an End If problem but darn it I guess not. Any other suggestions?

Dave wrote:
Hi,
Try removing the End If at the end of the sub.
Your If Then statements are only one line of code each, so the End If is not
required.
Regards - Dave.

I think I am trying to do too much in one line but I am not sure how to write
it correctly. I want the user to be able to click on cell P1 and then a

[quoted text clipped - 15 lines]
Thanks
Carrie


--
Message posted via OfficeKB.com
http://www.officekb.com/Uwe/Forums.a...tions/200805/1


--

Dave Peterson