hur göra en public variabel som jag kan anropa?

Petra

New Member
Joined
May 22, 2007
Messages
6
Hej,

kan jag i Thisworkbook skriva en kod där jag tilldelar rad ett värde som jag sedan kan använda i min kod som jag skriver i sheet1, sheet2 osv.

Det vill säga, om jag i thisworkbook har följande kod:

Public Sub Workbook_Open()
Dim rad As Integer

If Sheet1.Columns = 13 Then
rad = Target.Row
End If

End Sub

så skulle jag vilja i min kod i sheet1kunna använda "rad"
t.ex. såhär cells(rad, 13)

Hur skall jag göra så att jag kan anropa rad oberoende var jag skriver min kod?
 

Excel Facts

Format cells as time
Select range and press Ctrl+Shift+2 to format cells as time. (Shift 2 is the @ sign).
Hej!

Du behöver skriva

Code:
Public rad As Integer

Men detta behöver du ha i en vanlig modul, inte i thisworkbook eller i sheet modulen.

Sen skall du naturligtvis ta bort det Dim statment du redan har i koden.
 
Upvote 0

Forum statistics

Threads
1,223,948
Messages
6,175,565
Members
452,652
Latest member
eduedu

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