Reply
 
LinkBack Thread Tools Search this Thread Display Modes
  #1   Report Post  
Posted to microsoft.public.excel.programming
external usenet poster
 
Posts: 108
Default Array or InStr Difficulty

I have a block of code that currently runs down one column (D), looping
through rows based on a count I pull from the data set. I need this code to
run down several discontinuous columns. Im not familiar enough with arrays
or InStr to have this code run down columns (F [6], H [8], J [10, etc€¦). My
code pulls the number of rows and columns in the data set but Im finding it
confusing as how to loop through those discontinuous columns, 12 including
column (D). If I could be pointed in the right direction €“ that would be
greatly appreciated.
Sincerely,
Arturo

Sub Reverse()
Dim myRange As Range
Dim rO As Integer
Dim coL As Integer
Dim LoopCount_C As Integer
Dim LoopCount_R As Integer
Dim VarA As Variant
Dim VarB As Variant


''' Rows("1:9").Delete Shift:=xlUp
Range("A1").Select
Application.ScreenUpdating = False
Set myRange = ActiveCell.CurrentRegion
rO = myRange.Rows.Count - 1
coL = myRange.Columns.Count
' Q3- SQ1
Range("D2").Select
''' Array Needed Here.
For LoopCount_R = 1 To rO
VarA = ActiveCell.Value
If VarA = 8 Or VarA = "" Then
VarA = ""
Else: VarA = 8 - VarA
End If
ActiveCell.Value = VarA
ActiveCell.Offset(1, 0).Select
Next
''' Range("A1").Select
Application.ScreenUpdating = True
End Sub
  #2   Report Post  
Posted to microsoft.public.excel.programming
external usenet poster
 
Posts: 6,953
Default Array or InStr Difficulty

Sub Reverse()
Dim myRange As Range
Dim rO As Integer
Dim coL As Integer
Dim LoopCount_C As Integer
Dim LoopCount_R As Integer
Dim VarA As Variant
Dim VarB As Variant
Dim v as Variant

''' Rows("1:9").Delete Shift:=xlUp
Range("A1").Select
Application.ScreenUpdating = False
Set myRange = ActiveCell.CurrentRegion
rO = myRange.Rows.Count - 1
coL = myRange.Columns.Count
' Q3- SQ1
Range("D2").Select
v = Array(6,8,10,12,20,28,40,...,200)
for i = 0 to ubound(v)
For LoopCount_R = 1 To rO
cells(LoopCount_R,v(i)).Select
VarA = ActiveCell.Value
If VarA = 8 Or VarA = "" Then
VarA = ""
Else: VarA = 8 - VarA
End If
ActiveCell.Value = VarA
Next LoopCount_R
Next i
''' Range("A1").Select
Application.ScreenUpdating = True
End Sub


--
Regards,
Tom Ogilvy

"Arturo" wrote:

I have a block of code that currently runs down one column (D), looping
through rows based on a count I pull from the data set. I need this code to
run down several discontinuous columns. Im not familiar enough with arrays
or InStr to have this code run down columns (F [6], H [8], J [10, etc€¦). My
code pulls the number of rows and columns in the data set but Im finding it
confusing as how to loop through those discontinuous columns, 12 including
column (D). If I could be pointed in the right direction €“ that would be
greatly appreciated.
Sincerely,
Arturo

Sub Reverse()
Dim myRange As Range
Dim rO As Integer
Dim coL As Integer
Dim LoopCount_C As Integer
Dim LoopCount_R As Integer
Dim VarA As Variant
Dim VarB As Variant


''' Rows("1:9").Delete Shift:=xlUp
Range("A1").Select
Application.ScreenUpdating = False
Set myRange = ActiveCell.CurrentRegion
rO = myRange.Rows.Count - 1
coL = myRange.Columns.Count
' Q3- SQ1
Range("D2").Select
''' Array Needed Here.
For LoopCount_R = 1 To rO
VarA = ActiveCell.Value
If VarA = 8 Or VarA = "" Then
VarA = ""
Else: VarA = 8 - VarA
End If
ActiveCell.Value = VarA
ActiveCell.Offset(1, 0).Select
Next
''' Range("A1").Select
Application.ScreenUpdating = True
End Sub

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
InStr Harley Excel Programming 3 August 9th 05 08:55 PM
InStr FGM Excel Programming 3 July 14th 05 08:47 PM
InStr and ADO Al Excel Programming 2 June 17th 04 04:22 PM
InStr used in SQL query dchow Excel Programming 3 July 21st 03 09:09 AM


All times are GMT +1. The time now is 07:06 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"