Reply
 
LinkBack Thread Tools Search this Thread Display Modes
  #1   Report Post  
Posted to microsoft.public.excel.programming
external usenet poster
 
Posts: 96
Default variable target address

i have two worksheets...one that has a list of names , and a detail sheet
that has data for each name.

i am looking to have a macro that would create a third sheet that summarizes
the detail in the data sheet for the name that is double clicked in the name
sheet without having to create a separate macro for each name. is this
possible?
  #2   Report Post  
Posted to microsoft.public.excel.programming
external usenet poster
 
Posts: 489
Default variable target address

Put this in the Names Worksheet Module. When ever you double click the name
it will find the data in Data worksheet and put it in summary worksheet. You
need to relabel your worksheets, Names, Data, & Summary. Let me know if you
need me to expand on this code. Hope this helps! If so, let me know, click
"YES" below.
Option Explicit

Private Sub Worksheet_BeforeDoubleClick(ByVal Target As Range, Cancel As
Boolean)

Dim rngSearchRange As Range
Dim rngFound As Range
Dim lngLastRow As Long

Cancel = True

With Sheets("Data")
lngLastRow = .Cells(Rows.Count, "A").End(xlUp).Row

Set rngSearchRange = .Range("A1:A" & lngLastRow)

Set rngFound = rngSearchRange.Find(What:=Target.Value, _
LookIn:=xlValues, _
LookAt:=xlWhole, _
SearchOrder:=xlByRows, _
SearchDirection:=xlNext, _
MatchCase:=True, _
SearchFormat:=False)
End With

If Not rngFound Is Nothing Then
With Sheets("Summary")
lngLastRow = .Cells(Rows.Count, "A").End(xlUp).Row + 1
.Cells(lngLastRow, "A").Value = Target.Value
.Cells(lngLastRow, "B").Value = rngFound.Offset(0, 1).Value
End With
MsgBox Target.Value & " has been added to the Summary sheet."
Else
MsgBox Target.Value & " was not found in Data Sheet.", vbInformation
End If

End Sub
--
Cheers,
Ryan


"joemeshuggah" wrote:

i have two worksheets...one that has a list of names , and a detail sheet
that has data for each name.

i am looking to have a macro that would create a third sheet that summarizes
the detail in the data sheet for the name that is double clicked in the name
sheet without having to create a separate macro for each name. is this
possible?

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
Target.Address Question Leiprecht Excel Programming 3 April 13th 09 08:33 PM
Can you use a Range $N$xx:$Q$xx in Target.Address? CRayF Excel Programming 7 December 14th 06 09:11 PM
Using Target.Address in Excel 98 Noemi Excel Discussion (Misc queries) 2 November 7th 05 01:36 PM
Target.Address syntax Coolboy55 Excel Worksheet Functions 3 August 23rd 05 12:23 AM
target address Mark Kubicki Excel Programming 2 October 31st 03 04:19 PM


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