Reply
 
LinkBack Thread Tools Search this Thread Display Modes
  #1   Report Post  
Posted to microsoft.public.excel.programming
external usenet poster
 
Posts: 56
Default Looping letters (or columns)

I have a section of code that runs muliply times that could be reduced to a
loop if I could figure out the syntax. Looking for help with this:

' Alternating Safety Lights
If ThisWorkbook.Worksheets("Sheet1").Range("A19") = True Then
destWB.Worksheets("Sheet1").Range("H" & Lr) = "X"
End If
' Bed Step
If ThisWorkbook.Worksheets("Sheet1").Range("A20") = True Then
destWB.Worksheets("Sheet1").Range("I" & Lr) = "X"
End If
' Blanket Can Holder
If ThisWorkbook.Worksheets("Sheet1").Range("A21") = True Then
destWB.Worksheets("Sheet1").Range("J" & Lr) = "X"
End If
' Canopy Roof
If ThisWorkbook.Worksheets("Sheet1").Range("A22") = True Then
destWB.Worksheets("Sheet1").Range("K" & Lr) = "X"
End If

Each if loop is basically for a different part (There are 38 parts). The
loop needed must change the Range("Axx") value (I can do this pretty easy,
for xx=19 to 22), the part I nee help with is the Letter or Column loop
changing the Range("X" & Lr) from H to K. Anyone have any simple ideas?
  #2   Report Post  
Posted to microsoft.public.excel.programming
external usenet poster
 
Posts: 339
Default Looping letters (or columns)

Something like this? I am not sure I understand "changing the Range("X" &
Lr) from H to K"

Public Sub test()
Dim i As Long

For i = 19 To 21 ' Or whatever
If ThisWorkbook.Worksheets("Sheet1").Range("A" & CStr(i)) = True Then
destWB.Worksheets("Sheet1").Range("H" & Lr) = "X"
End If
Next
End Sub

/Fredrik

"JCanyoneer" wrote in message
...
I have a section of code that runs muliply times that could be reduced to

a
loop if I could figure out the syntax. Looking for help with this:

' Alternating Safety Lights
If ThisWorkbook.Worksheets("Sheet1").Range("A19") = True Then
destWB.Worksheets("Sheet1").Range("H" & Lr) = "X"
End If
' Bed Step
If ThisWorkbook.Worksheets("Sheet1").Range("A20") = True Then
destWB.Worksheets("Sheet1").Range("I" & Lr) = "X"
End If
' Blanket Can Holder
If ThisWorkbook.Worksheets("Sheet1").Range("A21") = True Then
destWB.Worksheets("Sheet1").Range("J" & Lr) = "X"
End If
' Canopy Roof
If ThisWorkbook.Worksheets("Sheet1").Range("A22") = True Then
destWB.Worksheets("Sheet1").Range("K" & Lr) = "X"
End If

Each if loop is basically for a different part (There are 38 parts). The
loop needed must change the Range("Axx") value (I can do this pretty easy,
for xx=19 to 22), the part I nee help with is the Letter or Column loop
. Anyone have any simple ideas?



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
Columns now numbers rather than letters how do i get letters back SalExcel10 Excel Discussion (Misc queries) 2 March 4th 10 02:48 PM
looping across columns in range? Amy Excel Discussion (Misc queries) 3 July 19th 05 08:01 PM
Looping through columns teresa Excel Programming 2 December 31st 04 07:25 PM
Looping thru columns beyond Z John Pierce Excel Programming 3 January 23rd 04 12:17 AM
Looping question for 2 columns [email protected] Excel Programming 1 October 24th 03 02:33 PM


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

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

About Us

"It's about Microsoft Excel"