Reply
 
LinkBack Thread Tools Search this Thread Display Modes
  #1   Report Post  
Posted to microsoft.public.excel.programming
ble ble is offline
external usenet poster
 
Posts: 5
Default Using contents of cells as input for variable?

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
Reply
Thread Tools Search this Thread
Search this Thread:

Advanced Search
Display Modes

Posting Rules

Smilies are On
[IMG] code is On
HTML code is Off
Trackbacks are On
Pingbacks are On
Refbacks are On


Similar Threads
Thread Thread Starter Forum Replies Last Post
concatenate contents of cells whose contents resemble cell referem cathyh Excel Worksheet Functions 3 May 23rd 09 12:16 PM
macro with input msg based on cell contents Janelle S[_2_] Excel Discussion (Misc queries) 2 February 9th 08 11:47 PM
Multiplying the contents of two cells a variable number of times Stephen Brown Excel Worksheet Functions 1 September 6th 06 09:22 AM
Copy cell contents using Input Box cottage6 Excel Programming 4 September 19th 05 06:05 PM
Making Contents of a cell input for a Module anyuan Excel Programming 0 June 28th 04 06:49 AM


All times are GMT +1. The time now is 06:20 PM.

Powered by vBulletin® Copyright ©2000 - 2025, Jelsoft Enterprises Ltd.
Copyright ©2004-2025 ExcelBanter.
The comments are property of their posters.
 

About Us

"It's about Microsoft Excel"