View Single Post
  #3   Report Post  
Posted to microsoft.public.excel.programming
Anna Anna is offline
external usenet poster
 
Posts: 132
Default Using a string to reference an address

Here's the rest of the code:

Private Sub SelectColumn()

Dim rngDateFound As Range
Dim rngCodeFound As Range
Dim rngToSearch As Range
Dim rngFinal As Range
Dim wks As Worksheet
Dim wksreport As Worksheet
Dim strCell As String

Set wks = Sheets("worksheet")
Set wksreport = Sheets("report")
Set rngToSearch = wks.Cells
Set rngDateFound = rngToSearch.Find(What:=Date, _
LookIn:=xlFormulas, _
LookAt:=xlWhole, _
MatchCase:=False)
'Current date is not found
If rngDateFound Is Nothing Then
MsgBox "Sorry, the current date is not a valid parameter."
'Current date is found
Else
Set rngToSearch = rngDateFound.EntireColumn
Set rngCodeFound = rngToSearch.Find(What:="FTO", _
LookIn:=xlFormulas, _
LookAt:=xlWhole, _
MatchCase:=False)
'Code is not found
If rngCodeFound Is Nothing Then
MsgBox "No FTO"
'Code is found
Else
strCell = rngCodeFound.Address
strCell = Right(strCell, 2)
strCell = ("A" + strCell)
MsgBox strCell
End If
End If

End Sub

I did try inserting your statement, instead of my long path of getting the
cell's address, but I got an "Invalid QUalifier" error.

"Don Guillett" wrote:

post all of your code pertaining to this. Maybe?

strCell.value ="A"& right( rngCodeFound,2)


--
Don Guillett
SalesAid Software

"anna" wrote in message
...
I want to use my strCell to reference an address, such as "A1" - how would
I
copy this cell? strCell.Copy does not work - I'm assuming it is because I
am
using a string and excel can't read my mind :)

If rngCodeFound Is Nothing Then
MsgBox "No FTO"
'Code is found
Else
strCell = rngCodeFound.Address
strCell = Right(strCell, 2)
strCell = ("A" + strCell)
' copy the cell that strCell variable references
' paste the copied cell to a new wks
End If