I'm a beginner with VBA Excel and I'm trying to do an application for my thesis, that has to manipulate excel files during the process.
I will basically have a workbook composed by many worksheets, and I want to save effectively some data, using only one FOR to save some time. The problem is that I don't know which are going to be the names of the worksheets imported (already done this importation part).
So, I want to save the columns where I found some data (strings 'Create' and 'Delete'), but I can't assign them to a static variable, because they'll be overwritten. So my idea was to put them on dynamic variables, according to the name of the sheet, but I don't know how to do that.
My first try was the following, but the code doesn't work... ws.Name & c = w and ws.Name & d = w are giving error.
For Each ws In ThisWorkbook.Worksheets
If ws.Name <> "Sheet1" And ws.Name <> concepts Then
For w = 1 To ws.Name.Cells(1, Columns.Count).End(xlToLeft).Column
If ws.Name.Cells(1, w).Value = create Then
ws.Name & "c" = w
ElseIf ws.Name.Cells(1, w).Value = delete Then
ws.Name & "d" = w
End If
Next w
EndIf
Next
Can someone please help me?
createanddeleteare variables. If you're trying to see if the value is the strings, then you need to wrap those in quotes, e.g.... = "create", or... = "delete".CollectionorDictionaryof valuesFor-loop each of the variables would only have a single value. If there is more than one create or destroy per sheet, the code would only save thewvalue for the last one.