I guess I don't understand, I am familiar with sheet and cell reference in a spreadsheet but I can't seem to apply the concept in a macro. Below is the macro that I use to select a subst of the colums. When I want to select different colums, I edit the col names below. These names are used in several different way in later macros, so I need to edit the there as well.
'
' Copy Las Data to QCData sheet
'
'
Sheets("LAS Load").Select
Cells.Select
Selection.Copy
Sheets("QCData").Select
Range("A1").Select
ActiveSheet.Paste
' Rename ~A to CutOff
Range("A1").Select
Application.CutCopyMode = False
ActiveCell.FormulaR1C1 = "CutOff"
'
' This section deletes columns not needed from raw data
' Add/change mnemonics below to specify channels to be saved
'
Sheets("QCData").Select
Dim i As Long
For i = Cells(1, Columns.Count).End(xlToLeft).Column To 1 Step -1
If Cells(1, i) <> "CutOff" _
And Cells(1, i) <> "TIME" _
And Cells(1, i) <> "LSPD" _
And Cells(1, i) <> "ADPTH" _
And Cells(1, i) <> "TEMP" _
And Cells(1, i) <> "FLOWA3" _
And Cells(1, i) <> "FLOWB3" _
And Cells(1, i) <> "FLOWC3" _
And Cells(1, i) <> "FLOWA2" _
And Cells(1, i) <> "FLOWB2" _
And Cells(1, i) <> "FLOWC2" _
Then Columns(i).Delete
Next i
'
' End Sub
I was hoping to add a worksheet to the workbook (here named INFO) in which I can change column names and function variables that are then read by the macro. As an example in the INFO sheet I might change the name of the last column I wish to keep by entering its name in A11. The following reference in the macro does not work as intended.
'
' This section deletes columns not needed from raw data
' Add/change mnemonics below to specify channels to be saved
'
Sheets("QCData").Select
Dim i As Long
For i = Cells(1, Columns.Count).End(xlToLeft).Column To 1 Step -1
If Cells(1, i) <> "CutOff" _
And Cells(1, i) <> "TIME" _
And Cells(1, i) <> "LSPD" _
And Cells(1, i) <> "ADPTH" _
And Cells(1, i) <> "TEMP" _
And Cells(1, i) <> "FLOWA3" _
And Cells(1, i) <> "FLOWB3" _
And Cells(1, i) <> "FLOWC3" _
And Cells(1, i) <> "FLOWA2" _
And Cells(1, i) <> "FLOWB2" _
And Cells(1, i) <> "=INFO!$A$11" _
Then Columns(i).Delete
Next i
'
' End Sub
Bookmarks