Public Range

Eziooh

New Member
Joined
Apr 1, 2019
Messages
17
Hello, I think it is a noob question but...

How can I range a cell with a variable to a module?
My code right now is pretty simple, this is on the actual sheet:

Code:
Private Sub Worksheet_Change(ByVal Target As Range)    If Target.Address = "$D$7" Then
        Call Procurar
    End If
End Sub

And in the module code I want to use a variable which ranges the target address...
Is it possible? If it is, how?
Thanks for the time!
 

Excel Facts

Format cells as time
Select range and press Ctrl+Shift+2 to format cells as time. (Shift 2 is the @ sign).
One option is
Code:
Private Sub Worksheet_Change(ByVal Target As Range)
   If Target.Address = "$D$7" Then
        Call Procurar[COLOR=#ff0000](Target)[/COLOR]
    End If
End Sub
and
Code:
Sub Procurar([COLOR=#ff0000]Rng As Range[/COLOR])
MsgBox Rng.Address
End Sub
 
Upvote 0
And how do I use it here? Sorry bothering...

Code:
Sub Procurar(rng As Range)Dim lastrow As Long
Dim Cell, cRange As Range
Dim valor, resultado As String
MsgBox rng.Address
valor = Worksheets("sheet1").Range() ' I need it here

End Sub
 
Upvote 0
Is the Change event running on sheet1?
 
Upvote 0
In that case
Code:
Sub Procurar(rng As Range)
Dim lastrow As Long
Dim Cell, cRange As Range
Dim valor, resultado As String

valor = rng.Value ' I need it here

End Sub
 
Upvote 0
Do you mean you want the cell address, rather than the value?
 
Upvote 0
I need the cell address and the value of it, I will need the cell address later on the module code...
 
Upvote 0

Forum statistics

Threads
1,215,326
Messages
6,124,260
Members
449,149
Latest member
mwdbActuary

We've detected that you are using an adblocker.

We have a great community of people providing Excel help here, but the hosting costs are enormous. You can help keep this site running by allowing ads on MrExcel.com.
Allow Ads at MrExcel

Which adblocker are you using?

Disable AdBlock

Follow these easy steps to disable AdBlock

1)Click on the icon in the browser’s toolbar.
2)Click on the icon in the browser’s toolbar.
2)Click on the "Pause on this site" option.
Go back

Disable AdBlock Plus

Follow these easy steps to disable AdBlock Plus

1)Click on the icon in the browser’s toolbar.
2)Click on the toggle to disable it for "mrexcel.com".
Go back

Disable uBlock Origin

Follow these easy steps to disable uBlock Origin

1)Click on the icon in the browser’s toolbar.
2)Click on the "Power" button.
3)Click on the "Refresh" button.
Go back

Disable uBlock

Follow these easy steps to disable uBlock

1)Click on the icon in the browser’s toolbar.
2)Click on the "Power" button.
3)Click on the "Refresh" button.
Go back
Back
Top