Pass a string as an argument for a sub in VBA?

Viewed 63

I'm currently looking for a way to pass a string as an argument between 2 sub as you would do between two function in C or C++.

Here's an example of what I'm trying to do:

Sub Bouton1_Cliquer()

   Call Ouvrir_Workbook("test.xlsm")

End Sub


Sub Ouvrir_Workbook(ByVal name As String)

   Dim data As Workbook

   Set data = Workbooks.Open("C:\Users\whatever\name")

End Sub

The goal here is to find a way to simplify the code and make it more organized.

I've been coding VBA for less than a week and I'm still learning.

0 Answers
Related