Reply
 
LinkBack Thread Tools Search this Thread Display Modes
  #1   Report Post  
Posted to microsoft.public.excel.programming
external usenet poster
 
Posts: 1
Default overworking code, infinite running

Hello there,

I modified some code so that it will find cells in column A that ar
not blank, then add a new row above it and fill a cell with some text


The problem is simple

It finds a filled cell in column A inserns a new row and some text the
looks at the next row down (the same one it say in the first step) an
adds another row with the text and so on and so on and so on.


I tried to add a fix I could think of but not it just runs from the to
of the a column to the end + 25 rows.

here is the code with my current not-fix:

Sub DeletingStuffinA() ' deletes topcrop in the report
Range("A3").Select '
Do Until X = 25 'Change number for extra number of blanks between data
CaseText = activecell.Value
Select Case (CaseText)

Case Is < ""
selection.EntireRow.Insert
activecell.Offset(-1, 4) = "TOTAL TRANSACTIONS"
activecell.Offset(2, -4).Select
Y = 1

End Select
If Y = 1 Then
Else
activecell.Offset(1, 0).Select
End If
If activecell = "" Then
X = X + 1
Else
X = 0
End If
Y = 0
Loop
End Su

--
Message posted from http://www.ExcelForum.com

  #2   Report Post  
Posted to microsoft.public.excel.programming
external usenet poster
 
Posts: 1
Default overworking code, infinite running

Hello
Try this

Sub DeletingStuffinA() ' deletes topcrop in the report
Range("A3").Select '
Do Until ActiveCell.Row = 25 'Change number for extra
number of blanks between data
If ActiveCell.Text < "" Then
Selection.EntireRow.Insert
ActiveCell.Offset(-1, 4) = "TOTAL TRANSACTIONS"
ActiveCell.Offset(2, 0).Select
Else
ActiveCell.Offset(1, 0).Select
End If
Loop
End Sub


THIS VERSION ONLY ADDS A BLANK ROW IF YOU NEED IT.

Sub DeletingStuffinA() ' deletes topcrop in the report
Range("A3").Select '
Do Until ActiveCell.Row = 25 'Change number for extra
number of blanks between data
If ActiveCell.Text < "" Then
If ActiveCell.Offset(-1, 0) < "" Then 'only inserts a
blank row if you need a blank row
Selection.EntireRow.Insert
ActiveCell.Offset(0, 4) = "TOTAL TRANSACTIONS"
ActiveCell.Offset(2, 0).Select
Else
ActiveCell.Offset(-1, 4) = "TOTAL TRANSACTIONS"
ActiveCell.Offset(1, 0).Select
End If
Else
ActiveCell.Offset(1, 0).Select
End If
Loop
End Sub


James


-----Original Message-----
Hello there,

I modified some code so that it will find cells in

column A that are
not blank, then add a new row above it and fill a cell

with some text.


The problem is simple

It finds a filled cell in column A inserns a new row and

some text then
looks at the next row down (the same one it say in the

first step) and
adds another row with the text and so on and so on and

so on.


I tried to add a fix I could think of but not it just

runs from the top
of the a column to the end + 25 rows.

here is the code with my current not-fix:

Sub DeletingStuffinA() ' deletes topcrop in the report
Range("A3").Select '
Do Until X = 25 'Change number for extra number of

blanks between data
CaseText = activecell.Value
Select Case (CaseText)

Case Is < ""
selection.EntireRow.Insert
activecell.Offset(-1, 4) = "TOTAL TRANSACTIONS"
activecell.Offset(2, -4).Select
Y = 1

End Select
If Y = 1 Then
Else
activecell.Offset(1, 0).Select
End If
If activecell = "" Then
X = X + 1
Else
X = 0
End If
Y = 0
Loop
End Sub


---
Message posted from http://www.ExcelForum.com/

.

  #3   Report Post  
Posted to microsoft.public.excel.programming
external usenet poster
 
Posts: 218
Default overworking code, infinite running

Is this what you want?

Sub DeletingStuffInA()
Dim i As Integer, X As Integer
i = 1: X = 0
Do Until X = 25
If Cells(i, 1) < "" Then
Cells(i, 5) = "Total Transactions"
Cells(i, 1).EntireRow.Insert
i = i + 2
Else
X = X + 1
i = i + 1
End If
Loop
End Sub

Regards,
Greg


-----Original Message-----
Hello there,

I modified some code so that it will find cells in column

A that are
not blank, then add a new row above it and fill a cell

with some text.


The problem is simple

It finds a filled cell in column A inserns a new row and

some text then
looks at the next row down (the same one it say in the

first step) and
adds another row with the text and so on and so on and so

on.


I tried to add a fix I could think of but not it just

runs from the top
of the a column to the end + 25 rows.

here is the code with my current not-fix:

Sub DeletingStuffinA() ' deletes topcrop in the report
Range("A3").Select '
Do Until X = 25 'Change number for extra number of blanks

between data
CaseText = activecell.Value
Select Case (CaseText)

Case Is < ""
selection.EntireRow.Insert
activecell.Offset(-1, 4) = "TOTAL TRANSACTIONS"
activecell.Offset(2, -4).Select
Y = 1

End Select
If Y = 1 Then
Else
activecell.Offset(1, 0).Select
End If
If activecell = "" Then
X = X + 1
Else
X = 0
End If
Y = 0
Loop
End Sub


---
Message posted from http://www.ExcelForum.com/

.

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
Running code on workdays chrisnsmith Excel Worksheet Functions 2 February 4th 09 06:58 PM
VB code for running a macro rcc Excel Discussion (Misc queries) 3 January 23rd 08 02:53 AM
running code mark New Users to Excel 3 March 14th 05 09:14 AM
Running Code Automatically Bruno[_2_] Excel Programming 2 January 31st 04 06:26 AM
running VB code Cath[_3_] Excel Programming 1 November 21st 03 05:09 PM


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