Reply
 
LinkBack Thread Tools Search this Thread Display Modes
  #1   Report Post  
Posted to microsoft.public.excel.programming
Ayo Ayo is offline
external usenet poster
 
Posts: 489
Default BeforeDoubleClick Event not working

I have this BeforeDoubleClick event, below, that I am trying to run.
Everything was working fine yesterday now, it just jumps from the "If" to
the "End If" statements. I can't figure out what's going on.
Any ideas?

Private Sub Worksheet_BeforeDoubleClick(ByVal Target As Range, Cancel As
Boolean)
Dim errorWS As Worksheet, siteWS As Worksheet
Dim i As Integer, rw As Integer

Set siteWS = Worksheets("Site Milestone Dates")
Set errorWS = Worksheets("Error_MarketList")
errorWS_lastRow = errorWS.Range("A65536").End(xlUp).Row

If Target.Address() = "$A$5" Or Target.Address() <= "$A$" &
errorWS_lastRow Then
Application.EnableEvents = False
Application.ScreenUpdating = False

siteWS.Range("C4").Value = Target.Value
siteWS.Range("E4").Value = UCase(Target.Offset(0, 1).Value)

rw = 7
For i = 2 To 23 Step 2
siteWS.Range("E" & rw).Value = Target.Offset(0, i).Value
siteWS.Range("G" & rw).Value = Target.Offset(0, i + 1).Value
rw = rw + 2
Next i

rw = 7
For i = 24 To 45 Step 2
siteWS.Range("M" & rw).Value = Target.Offset(0, i).Value
siteWS.Range("O" & rw).Value = Target.Offset(0, i + 1).Value
rw = rw + 2
Next i

Application.EnableEvents = True
Application.ScreenUpdating = True
End If
siteWS.Select
End Sub
  #2   Report Post  
Posted to microsoft.public.excel.programming
external usenet poster
 
Posts: 489
Default BeforeDoubleClick Event not working

It seems to me your If...Then statement is setup wrong. I assume you are
wanting the code inside the If...Then statement to run if the user double
clicks any cell in Col.A that is greater that 4, right? If so, change your
If...Then statement from

If Target.Address() = "$A$5" Or Target.Address() <= "$A$" &
errorWS_lastRow Then

to this...

If Not Intersect(Target, errorWS.Range("A5:A" & errorWS_LastRow)) Is Nothing
Then

Plus, don't forget to declare your variables. errorWS_LastRow should be
declared as Long.

Plus, use this code to find you last cell with data. This will work for all
versions of Excel.

errorWS_LastRow = errorWS.Cells(Rows.Count, "A").End(xlUp).Row

Hope this helps! If so, let me know, click "YES" below.

--
Cheers,
Ryan


"Ayo" wrote:

I have this BeforeDoubleClick event, below, that I am trying to run.
Everything was working fine yesterday now, it just jumps from the "If" to
the "End If" statements. I can't figure out what's going on.
Any ideas?

Private Sub Worksheet_BeforeDoubleClick(ByVal Target As Range, Cancel As
Boolean)
Dim errorWS As Worksheet, siteWS As Worksheet
Dim i As Integer, rw As Integer

Set siteWS = Worksheets("Site Milestone Dates")
Set errorWS = Worksheets("Error_MarketList")
errorWS_lastRow = errorWS.Range("A65536").End(xlUp).Row

If Target.Address() = "$A$5" Or Target.Address() <= "$A$" &
errorWS_lastRow Then
Application.EnableEvents = False
Application.ScreenUpdating = False

siteWS.Range("C4").Value = Target.Value
siteWS.Range("E4").Value = UCase(Target.Offset(0, 1).Value)

rw = 7
For i = 2 To 23 Step 2
siteWS.Range("E" & rw).Value = Target.Offset(0, i).Value
siteWS.Range("G" & rw).Value = Target.Offset(0, i + 1).Value
rw = rw + 2
Next i

rw = 7
For i = 24 To 45 Step 2
siteWS.Range("M" & rw).Value = Target.Offset(0, i).Value
siteWS.Range("O" & rw).Value = Target.Offset(0, i + 1).Value
rw = rw + 2
Next i

Application.EnableEvents = True
Application.ScreenUpdating = True
End If
siteWS.Select
End Sub

  #3   Report Post  
Posted to microsoft.public.excel.programming
Ayo Ayo is offline
external usenet poster
 
Posts: 489
Default BeforeDoubleClick Event not working

Thanks Ryan. Works great so far.

"Ryan H" wrote:

It seems to me your If...Then statement is setup wrong. I assume you are
wanting the code inside the If...Then statement to run if the user double
clicks any cell in Col.A that is greater that 4, right? If so, change your
If...Then statement from

If Target.Address() = "$A$5" Or Target.Address() <= "$A$" &
errorWS_lastRow Then

to this...

If Not Intersect(Target, errorWS.Range("A5:A" & errorWS_LastRow)) Is Nothing
Then

Plus, don't forget to declare your variables. errorWS_LastRow should be
declared as Long.

Plus, use this code to find you last cell with data. This will work for all
versions of Excel.

errorWS_LastRow = errorWS.Cells(Rows.Count, "A").End(xlUp).Row

Hope this helps! If so, let me know, click "YES" below.

--
Cheers,
Ryan


"Ayo" wrote:

I have this BeforeDoubleClick event, below, that I am trying to run.
Everything was working fine yesterday now, it just jumps from the "If" to
the "End If" statements. I can't figure out what's going on.
Any ideas?

Private Sub Worksheet_BeforeDoubleClick(ByVal Target As Range, Cancel As
Boolean)
Dim errorWS As Worksheet, siteWS As Worksheet
Dim i As Integer, rw As Integer

Set siteWS = Worksheets("Site Milestone Dates")
Set errorWS = Worksheets("Error_MarketList")
errorWS_lastRow = errorWS.Range("A65536").End(xlUp).Row

If Target.Address() = "$A$5" Or Target.Address() <= "$A$" &
errorWS_lastRow Then
Application.EnableEvents = False
Application.ScreenUpdating = False

siteWS.Range("C4").Value = Target.Value
siteWS.Range("E4").Value = UCase(Target.Offset(0, 1).Value)

rw = 7
For i = 2 To 23 Step 2
siteWS.Range("E" & rw).Value = Target.Offset(0, i).Value
siteWS.Range("G" & rw).Value = Target.Offset(0, i + 1).Value
rw = rw + 2
Next i

rw = 7
For i = 24 To 45 Step 2
siteWS.Range("M" & rw).Value = Target.Offset(0, i).Value
siteWS.Range("O" & rw).Value = Target.Offset(0, i + 1).Value
rw = rw + 2
Next i

Application.EnableEvents = True
Application.ScreenUpdating = True
End If
siteWS.Select
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
Help With BeforeDoubleClick jean Excel Programming 3 March 19th 08 07:02 PM
BeforeDoubleClick Stefi Excel Programming 7 December 20th 07 10:13 AM
i want to know about "beforedoubleclick" event gopal singh Excel Programming 1 March 21st 06 03:31 PM
BeforeDoubleClick Cancel=True not working Reggie Excel Programming 1 September 20th 05 03:43 AM


All times are GMT +1. The time now is 07:50 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"