0

I am new to VBA and got that problem which I don't know how to fix. I have a workbook with some sheets and I create a new workbook for each sheet in that first one with the name of the sheets. That works... Now, I declare a variable of type string which defines the path to one of these new workbooks.
After defining that string I use that in the open function and when i change something in that workbook i opened, it also changes it in the worksheet where i get the name from(e.g. the name of the worksheet, like below)

Public Sub ProcessWorksheet(ByVal Worksheet As Excel.Worksheet)
     Dim fileName As String
     Dim currProFile as Workbook
     Dim currProSheet as Worksheet
     fileName ="some path" & "\" & worksheet.name & ".xlsx"
     Set currProFile = Workbooks.Open(fileName)
     Set currProSheet = currProFile.ActiveSheet
     currProSheet.name = "DATA"
End Sub

So I think there is a reference to that worksheet i just use for the name cause of that worksheet.name.
My question is: How can I get the name without a reference to the worksheet.

I hope it is all cleal and thanks for help!

1 Answer 1

0

Well, I started all over again and just used the most important code and now it works. I don't know why but it does. So I think it was just an error by Excel itself. Anyways thank you braX for editing advice

Sign up to request clarification or add additional context in comments.

Comments

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service and acknowledge you have read our privacy policy.

Start asking to get answers

Find the answer to your question by asking.

Ask question

Explore related questions

See similar questions with these tags.