LinkBack Thread Tools Search this Thread Display Modes
Prev Previous Post   Next Post Next
  #1   Report Post  
Posted to microsoft.public.excel.programming
external usenet poster
 
Posts: 3
Default How do I reference a Range of cells in excel using variable names

I am trying to find users (email address) in a range within a single column.
The column changes as I process worksheets. I have a list of contacts in
another worksheet:

In the code below I explain which statement works and which one fails. I
need a method to move from column to column searching for matching email
addresses.

I appreciate any help you can give to solve this problem. I'm open to all
suggestions.

Thanks, Kermitp

_____________________________________________
____________________________________________
Sub findeachopen()



gonogo = "Y"
contactCol = 2
' "NL-opens-by-NL" ' contains a Column (A) with master list of email
addresses and a column for each sent email
' "NL-opens" ' contains multple columns with list of who opened the email
' this sub finds if the person has open each email and marks the cell Y
or N in that email column
' this way we can determine how many emails each person has opened

While Not (IsEmpty(Worksheets("NL-opens-by-NL").Cells(1, contactCol).Value)
Or gonogo = "N")
contactstartrow = 2
contactRow = 2
contactlastrow = 300
headrow = 1

With Worksheets(1)
.Range(.Cells(1, 1), _
.Cells(10, 10)).Borders.LineStyle = xlThick
End With

While Not (IsEmpty(Worksheets("NL-opens-by-NL").Cells(contactRow,
"A").Value) Or gonogo = "N")

UserName = Worksheets("NL-opens-by-NL").Cells(contactRow, "A").Value
'
' The next statement get an error of Invalid or unqualified reference
'
With Worksheets("NL-opens").Range(.Cells(contactstartrow,
contactCol), .Cells(contactlastrow, contactCol))

'
' The next statement works but I can't change the Column in the range
' which I need to do in order to procees all columns
'
' With Worksheets("NL-opens").Range("B2:B300")

Set c = .Find(UserName, LookIn:=xlValues)
If Not c Is Nothing Then

Worksheets("NL-opens-by-NL").Cells(contactRow,
contactCol).Value = "Y"
Else
Worksheets("NL-opens-by-NL").Cells(contactRow,
contactCol).Value = "N"
End If
End With
contactRow = contactRow + 1

Wend

contactCol = contactCol + 1

Wend

End Sub


--
Kermit, long time windows Office user
 
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
Variable Names Range - Help Needed Les Excel Programming 4 July 15th 08 01:32 PM
reference other worksheets via variable names Huggy Excel Worksheet Functions 4 June 26th 08 05:52 AM
Is there a way to give range names (especially with relative reference) for series names and series values in Excel 2007 graphs? [email protected] Excel Programming 0 August 16th 07 02:52 PM
Variable names for named range Barb Reinhardt Excel Discussion (Misc queries) 4 March 19th 07 05:37 PM
How do I set up a variable reference range in Excel? Pecan1862 Excel Programming 1 January 27th 06 09:29 PM


All times are GMT +1. The time now is 07:19 PM.

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

About Us

"It's about Microsoft Excel"