Using contents of cells as input for variable?

B

ble

Have code like below multiple times for strings (walls, diameter, etc.) which
exist as headers in a sheet of my workbook. How do I id those cell contents
as a variable in For Each to reduce the code to one time for each variable??
"walls" would be replaced (3) places by the correct variable, and for each
subsequent until empty??.

Thanks in advance for any help.

'walls

Sheets("CONVERT dat").Select
Cells(myRow, 1).Select
ActiveCell.FormulaR1C1 = "=HLOOKUP(""walls"",RC[1]:RC[100],1,FALSE)"
Selection.Copy
Selection.PasteSpecial Paste:=xlPasteValues, Operation:=xlNone,
SkipBlanks _
:=False, Transpose:=False
ActiveCell.Replace What:="#N/A", Replacement:="1", LookAt:=xlPart, _
SearchOrder:=xlByRows, MatchCase:=False, SearchFormat:=False, _
ReplaceFormat:=False
ActiveCell.Replace What:="walls", Replacement:="2", LookAt:=xlPart, _
SearchOrder:=xlByRows, MatchCase:=False, SearchFormat:=False, _
ReplaceFormat:=False
If Selection = "2" Then
Cells(myRow, 2).Select
ActiveCell.EntireRow.Select
Cells.Find(What:="walls", After:=ActiveCell, LookIn:=xlFormulas, _
LookAt:=xlPart, SearchOrder:=xlByRows, SearchDirection:=xlNext, _
MatchCase:=False, SearchFormat:=False).Activate
ActiveCell.Offset(1, 0).Copy
Sheets("OUTPUT").Select
Cells(myRow2, 29).PasteSpecial
Else
Sheets("OUTPUT").Select
Cells(myRow2, 29).Select
ActiveCell.FormulaR1C1 = "N/A"
End If
 

Ask a Question

Want to reply to this thread or ask your own question?

You'll need to choose a username for the site, which only take a couple of moments. After that, you can post your question and our members will help you out.

Ask a Question

Top