Reply
 
LinkBack Thread Tools Search this Thread Display Modes
  #1   Report Post  
Posted to microsoft.public.excel.programming
external usenet poster
 
Posts: 115
Default Using Find/Replace in Visual basic to adapt the code



Is there are way of using either Find/Replace or some othe procedure within
Visual Basic to make global changes to a pattern of cells to be selected.

For example, if I wanted to select and delete 2 rows in a block, using say

Range ("A3:H3").Select and Range ("A66:H66").Select

then wanted to create another procedure which would select:

Range ("A3:H4").Select and Range ("A66:H67").Select etc etc

How would I do this?
  #2   Report Post  
Posted to microsoft.public.excel.programming
external usenet poster
 
Posts: 11,123
Default Using Find/Replace in Visual basic to adapt the code

If I understand you correct
You can use this

Range("A3:H3,A66:H66").Select

But you don't have to select

Range("A3:H3,A66:H66").EntireRow.Delete


--
Regards Ron de Bruin
http://www.rondebruin.nl


"Zakynthos" wrote in message ...


Is there are way of using either Find/Replace or some othe procedure within
Visual Basic to make global changes to a pattern of cells to be selected.

For example, if I wanted to select and delete 2 rows in a block, using say

Range ("A3:H3").Select and Range ("A66:H66").Select

then wanted to create another procedure which would select:

Range ("A3:H4").Select and Range ("A66:H67").Select etc etc

How would I do this?



  #3   Report Post  
Posted to microsoft.public.excel.programming
external usenet poster
 
Posts: 115
Default Using Find/Replace in Visual basic to adapt the code

'Ron,

Sorry, I didn't explain myself very well!!!!

I have a lot of data to process and 'recording' each macro I need to extract
data will be very time consuming, so I'm looking for as many shortcuts as I
can find!

Given that I have recorded a macro to delete ONE whole row (say, columns
a:h) in every 60 or so rows and I now want a macro (without having to go
through the long process of 'recording' it!) to delete TWO consecutive rows
in every 60 rows, how can I get a 'quick fix' (FInd/Replace???, but how???)
to replace ALL instances of a1:h1, a66-h66 etc with a1:h2, a66-h67 etc etc



"Ron de Bruin" wrote:

If I understand you correct
You can use this

Range("A3:H3,A66:H66").Select

But you don't have to select

Range("A3:H3,A66:H66").EntireRow.Delete


--
Regards Ron de Bruin
http://www.rondebruin.nl


"Zakynthos" wrote in message ...


Is there are way of using either Find/Replace or some othe procedure within
Visual Basic to make global changes to a pattern of cells to be selected.

For example, if I wanted to select and delete 2 rows in a block, using say

Range ("A3:H3").Select and Range ("A66:H66").Select

then wanted to create another procedure which would select:

Range ("A3:H4").Select and Range ("A66:H67").Select etc etc

How would I do this?




  #4   Report Post  
Posted to microsoft.public.excel.programming
external usenet poster
 
Posts: 5,441
Default Using Find/Replace in Visual basic to adapt the code

Zakynthos,

Use find/replace to replace

").Select

with

").Resize(2).Select

That will change all your select statements to select 2 rows.

HTH,
Bernie
MS Excel MVP


"Zakynthos" wrote in message
...
'Ron,

Sorry, I didn't explain myself very well!!!!

I have a lot of data to process and 'recording' each macro I need to extract
data will be very time consuming, so I'm looking for as many shortcuts as I
can find!

Given that I have recorded a macro to delete ONE whole row (say, columns
a:h) in every 60 or so rows and I now want a macro (without having to go
through the long process of 'recording' it!) to delete TWO consecutive rows
in every 60 rows, how can I get a 'quick fix' (FInd/Replace???, but how???)
to replace ALL instances of a1:h1, a66-h66 etc with a1:h2, a66-h67 etc etc



"Ron de Bruin" wrote:

If I understand you correct
You can use this

Range("A3:H3,A66:H66").Select

But you don't have to select

Range("A3:H3,A66:H66").EntireRow.Delete


--
Regards Ron de Bruin
http://www.rondebruin.nl


"Zakynthos" wrote in message
...


Is there are way of using either Find/Replace or some othe procedure within
Visual Basic to make global changes to a pattern of cells to be selected.

For example, if I wanted to select and delete 2 rows in a block, using say

Range ("A3:H3").Select and Range ("A66:H66").Select

then wanted to create another procedure which would select:

Range ("A3:H4").Select and Range ("A66:H67").Select etc etc

How would I do this?






  #5   Report Post  
Posted to microsoft.public.excel.programming
external usenet poster
 
Posts: 115
Default Using Find/Replace in Visual basic to adapt the code

Bernie,

Many thanks!! You've solved my problem.

Regards

Tony

"Bernie Deitrick" wrote:

Zakynthos,

Use find/replace to replace

").Select

with

").Resize(2).Select

That will change all your select statements to select 2 rows.

HTH,
Bernie
MS Excel MVP


"Zakynthos" wrote in message
...
'Ron,

Sorry, I didn't explain myself very well!!!!

I have a lot of data to process and 'recording' each macro I need to extract
data will be very time consuming, so I'm looking for as many shortcuts as I
can find!

Given that I have recorded a macro to delete ONE whole row (say, columns
a:h) in every 60 or so rows and I now want a macro (without having to go
through the long process of 'recording' it!) to delete TWO consecutive rows
in every 60 rows, how can I get a 'quick fix' (FInd/Replace???, but how???)
to replace ALL instances of a1:h1, a66-h66 etc with a1:h2, a66-h67 etc etc



"Ron de Bruin" wrote:

If I understand you correct
You can use this

Range("A3:H3,A66:H66").Select

But you don't have to select

Range("A3:H3,A66:H66").EntireRow.Delete


--
Regards Ron de Bruin
http://www.rondebruin.nl


"Zakynthos" wrote in message
...


Is there are way of using either Find/Replace or some othe procedure within
Visual Basic to make global changes to a pattern of cells to be selected.

For example, if I wanted to select and delete 2 rows in a block, using say

Range ("A3:H3").Select and Range ("A66:H66").Select

then wanted to create another procedure which would select:

Range ("A3:H4").Select and Range ("A66:H67").Select etc etc

How would I do this?








  #6   Report Post  
Posted to microsoft.public.excel.programming
external usenet poster
 
Posts: 11,123
Default Using Find/Replace in Visual basic to adapt the code

This example select the cells for testing
Use this line if it is working correct
'If Not rng Is Nothing Then rng.EntireRow.Delete

Sub UnionExample()
Dim Lrow As Long
Dim CalcMode As Long
Dim StartRow As Long
Dim EndRow As Long
Dim rng As Range

With Application
CalcMode = .Calculation
.Calculation = xlCalculationManual
.ScreenUpdating = False
End With

With ActiveSheet
.DisplayPageBreaks = False
StartRow = 1
EndRow = 10000
For Lrow = StartRow To EndRow Step 60
If rng Is Nothing Then
Set rng = .Cells(Lrow, "A").Resize(2, 1)
Else
Set rng = Application.Union(rng, .Cells(Lrow, "A").Resize(2, 1))
End If
Next
End With

'Delete all rows in one time
If Not rng Is Nothing Then rng.EntireRow.Select
'If Not rng Is Nothing Then rng.EntireRow.Delete

With Application
.ScreenUpdating = True
.Calculation = CalcMode
End With
End Sub



--
Regards Ron de Bruin
http://www.rondebruin.nl


"Zakynthos" wrote in message ...
'Ron,

Sorry, I didn't explain myself very well!!!!

I have a lot of data to process and 'recording' each macro I need to extract
data will be very time consuming, so I'm looking for as many shortcuts as I
can find!

Given that I have recorded a macro to delete ONE whole row (say, columns
a:h) in every 60 or so rows and I now want a macro (without having to go
through the long process of 'recording' it!) to delete TWO consecutive rows
in every 60 rows, how can I get a 'quick fix' (FInd/Replace???, but how???)
to replace ALL instances of a1:h1, a66-h66 etc with a1:h2, a66-h67 etc etc



"Ron de Bruin" wrote:

If I understand you correct
You can use this

Range("A3:H3,A66:H66").Select

But you don't have to select

Range("A3:H3,A66:H66").EntireRow.Delete


--
Regards Ron de Bruin
http://www.rondebruin.nl


"Zakynthos" wrote in message ...


Is there are way of using either Find/Replace or some othe procedure within
Visual Basic to make global changes to a pattern of cells to be selected.

For example, if I wanted to select and delete 2 rows in a block, using say

Range ("A3:H3").Select and Range ("A66:H66").Select

then wanted to create another procedure which would select:

Range ("A3:H4").Select and Range ("A66:H67").Select etc etc

How would I do this?






  #7   Report Post  
Posted to microsoft.public.excel.programming
external usenet poster
 
Posts: 115
Default Using Find/Replace in Visual basic to adapt the code

Ron,

Many thanks!!! Not sure I understand it all, but I'll certainly give it a go!

Best wishes

Tony

"Ron de Bruin" wrote:

This example select the cells for testing
Use this line if it is working correct
'If Not rng Is Nothing Then rng.EntireRow.Delete

Sub UnionExample()
Dim Lrow As Long
Dim CalcMode As Long
Dim StartRow As Long
Dim EndRow As Long
Dim rng As Range

With Application
CalcMode = .Calculation
.Calculation = xlCalculationManual
.ScreenUpdating = False
End With

With ActiveSheet
.DisplayPageBreaks = False
StartRow = 1
EndRow = 10000
For Lrow = StartRow To EndRow Step 60
If rng Is Nothing Then
Set rng = .Cells(Lrow, "A").Resize(2, 1)
Else
Set rng = Application.Union(rng, .Cells(Lrow, "A").Resize(2, 1))
End If
Next
End With

'Delete all rows in one time
If Not rng Is Nothing Then rng.EntireRow.Select
'If Not rng Is Nothing Then rng.EntireRow.Delete

With Application
.ScreenUpdating = True
.Calculation = CalcMode
End With
End Sub



--
Regards Ron de Bruin
http://www.rondebruin.nl


"Zakynthos" wrote in message ...
'Ron,

Sorry, I didn't explain myself very well!!!!

I have a lot of data to process and 'recording' each macro I need to extract
data will be very time consuming, so I'm looking for as many shortcuts as I
can find!

Given that I have recorded a macro to delete ONE whole row (say, columns
a:h) in every 60 or so rows and I now want a macro (without having to go
through the long process of 'recording' it!) to delete TWO consecutive rows
in every 60 rows, how can I get a 'quick fix' (FInd/Replace???, but how???)
to replace ALL instances of a1:h1, a66-h66 etc with a1:h2, a66-h67 etc etc



"Ron de Bruin" wrote:

If I understand you correct
You can use this

Range("A3:H3,A66:H66").Select

But you don't have to select

Range("A3:H3,A66:H66").EntireRow.Delete


--
Regards Ron de Bruin
http://www.rondebruin.nl


"Zakynthos" wrote in message ...


Is there are way of using either Find/Replace or some othe procedure within
Visual Basic to make global changes to a pattern of cells to be selected.

For example, if I wanted to select and delete 2 rows in a block, using say

Range ("A3:H3").Select and Range ("A66:H66").Select

then wanted to create another procedure which would select:

Range ("A3:H4").Select and Range ("A66:H67").Select etc etc

How would I do this?






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
Visual Basic code Pickle Excel Discussion (Misc queries) 1 September 4th 08 03:35 PM
I need a visual basic code....please Rhonda Excel Discussion (Misc queries) 1 March 5th 07 01:18 PM
Visual Basic code to find next available (blank) row in a spreadsh TB Excel Programming 2 July 15th 05 08:01 PM
visual basic code Whitey Excel Programming 1 October 26th 04 04:05 PM
Visual Basic Code Robert Couchman Excel Programming 2 February 2nd 04 03:10 PM


All times are GMT +1. The time now is 10:26 AM.

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"