Reply
 
LinkBack Thread Tools Search this Thread Display Modes
  #1   Report Post  
Posted to microsoft.public.excel.misc
Jeff
 
Posts: n/a
Default Skipping rows with VBA

Hello,
Here's my VBA Procedure.
I need to help: Is it possible to only evaluate the odd-numbered rows?

Sub trimit()
Dim a As Long
x = Mid(Application.Trim(Range("a5")), 12, 20)
For a = 1 To 100
If Cells(a, 1).Value 0 Then
Cells(a, 2).Value = x
Else
Cells(a, 2).Value = 0
End If
--
Regards,
Jeff

  #2   Report Post  
Posted to microsoft.public.excel.misc
Chip Pearson
 
Posts: n/a
Default Skipping rows with VBA

Jeff,

Try

x = Mid(Application.Trim(Range("a5")), 12, 20)
For a = 1 To 100
If a Mod 2 = 1 Then
If Cells(a, 1).Value 0 Then
Cells(a, 2).Value = x
Else
Cells(a, 2).Value = 0
End If
End If
Next a

--
Cordially,
Chip Pearson
Microsoft MVP - Excel
Pearson Software Consulting, LLC
www.cpearson.com



"Jeff" wrote in message
...
Hello,
Here's my VBA Procedure.
I need to help: Is it possible to only evaluate the
odd-numbered rows?

Sub trimit()
Dim a As Long
x = Mid(Application.Trim(Range("a5")), 12, 20)
For a = 1 To 100
If Cells(a, 1).Value 0 Then
Cells(a, 2).Value = x
Else
Cells(a, 2).Value = 0
End If
--
Regards,
Jeff



  #3   Report Post  
Posted to microsoft.public.excel.misc
Jeff
 
Posts: n/a
Default Skipping rows with VBA

Thank you Chip,
I made a misake. I meant even-numbered rows. Can you help?

--
Regards,
Jeff



"Chip Pearson" wrote:

Jeff,

Try

x = Mid(Application.Trim(Range("a5")), 12, 20)
For a = 1 To 100
If a Mod 2 = 1 Then
If Cells(a, 1).Value 0 Then
Cells(a, 2).Value = x
Else
Cells(a, 2).Value = 0
End If
End If
Next a

--
Cordially,
Chip Pearson
Microsoft MVP - Excel
Pearson Software Consulting, LLC
www.cpearson.com



"Jeff" wrote in message
...
Hello,
Here's my VBA Procedure.
I need to help: Is it possible to only evaluate the
odd-numbered rows?

Sub trimit()
Dim a As Long
x = Mid(Application.Trim(Range("a5")), 12, 20)
For a = 1 To 100
If Cells(a, 1).Value 0 Then
Cells(a, 2).Value = x
Else
Cells(a, 2).Value = 0
End If
--
Regards,
Jeff




  #4   Report Post  
Posted to microsoft.public.excel.misc
Chip Pearson
 
Posts: n/a
Default Skipping rows with VBA

For even numbered rows, change

If a Mod 2 = 1 Then

to

If a Mod 2 = 0 Then


--
Cordially,
Chip Pearson
Microsoft MVP - Excel
Pearson Software Consulting, LLC
www.cpearson.com



"Jeff" wrote in message
...
Thank you Chip,
I made a misake. I meant even-numbered rows. Can you help?

--
Regards,
Jeff



"Chip Pearson" wrote:

Jeff,

Try

x = Mid(Application.Trim(Range("a5")), 12, 20)
For a = 1 To 100
If a Mod 2 = 1 Then
If Cells(a, 1).Value 0 Then
Cells(a, 2).Value = x
Else
Cells(a, 2).Value = 0
End If
End If
Next a

--
Cordially,
Chip Pearson
Microsoft MVP - Excel
Pearson Software Consulting, LLC
www.cpearson.com



"Jeff" wrote in message
...
Hello,
Here's my VBA Procedure.
I need to help: Is it possible to only evaluate the
odd-numbered rows?

Sub trimit()
Dim a As Long
x = Mid(Application.Trim(Range("a5")), 12, 20)
For a = 1 To 100
If Cells(a, 1).Value 0 Then
Cells(a, 2).Value = x
Else
Cells(a, 2).Value = 0
End If
--
Regards,
Jeff






  #5   Report Post  
Posted to microsoft.public.excel.misc
Dave Peterson
 
Posts: n/a
Default Skipping rows with VBA

Another way:

For a = 1 To 100 Step 2
or
For a = 2 To 100 step 2

(depending on which ones you want to skip.)

Jeff wrote:

Hello,
Here's my VBA Procedure.
I need to help: Is it possible to only evaluate the odd-numbered rows?

Sub trimit()
Dim a As Long
x = Mid(Application.Trim(Range("a5")), 12, 20)
For a = 1 To 100
If Cells(a, 1).Value 0 Then
Cells(a, 2).Value = x
Else
Cells(a, 2).Value = 0
End If
--
Regards,
Jeff


--

Dave Peterson
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
Rows & Columns in Excel seadragon69 Excel Worksheet Functions 2 December 7th 05 05:54 PM
Automatically inserting rows ausdiver99 Excel Worksheet Functions 1 June 2nd 05 02:15 PM
Hiding Rows if the linked rows are blank KG Excel Discussion (Misc queries) 9 May 18th 05 02:32 AM
Trouble with skipping rows Wazooli Excel Worksheet Functions 1 March 23rd 05 02:19 PM
flexible paste rows function that inserts the right number of rows marika1981 Excel Discussion (Misc queries) 1 February 18th 05 02:40 AM


All times are GMT +1. The time now is 08:07 AM.

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"