Reply
 
LinkBack Thread Tools Search this Thread Display Modes
  #1   Report Post  
Posted to microsoft.public.excel.programming
Rob Rob is offline
external usenet poster
 
Posts: 234
Default Loop column A and delete and move on condition

Hi,
I'm trying to loop through cells in column A (say rows 1 to 500) and if the
length of contents is 0, clear contents as there will be apostrophes in the
cells. If on the other hand the length of contents is greater than 0, I
want to place the contents from column A in column C of the same row, whilst
removing the contents of column A.

I've tried various pieces of code but run into Debug mode!

Thanks, Rob


  #2   Report Post  
Posted to microsoft.public.excel.programming
external usenet poster
 
Posts: 11,123
Default Loop column A and delete and move on condition

If you have two '' in a cell Len will count 1.
What do you do then?


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



"Rob" wrote in message ...
Hi,
I'm trying to loop through cells in column A (say rows 1 to 500) and if the length of contents is 0, clear contents as there will
be apostrophes in the cells. If on the other hand the length of contents is greater than 0, I want to place the contents from
column A in column C of the same row, whilst removing the contents of column A.

I've tried various pieces of code but run into Debug mode!

Thanks, Rob



  #3   Report Post  
Posted to microsoft.public.excel.programming
Rob Rob is offline
external usenet poster
 
Posts: 234
Default Loop column A and delete and move on condition

Ron,

Because the apostrophes are set by a previous routine, there will only be
two tests: firstly whether the cell appears empty but has an apostrophe or
whether there is some text.

I'm really interested in moving the text from column A to CO but can't just
copy and paste as there is other contents in column CO.

Thanks, Rob

"Ron de Bruin" wrote in message
...
If you have two '' in a cell Len will count 1.
What do you do then?


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



"Rob" wrote in message
...
Hi,
I'm trying to loop through cells in column A (say rows 1 to 500) and if
the length of contents is 0, clear contents as there will be apostrophes
in the cells. If on the other hand the length of contents is greater
than 0, I want to place the contents from column A in column C of the
same row, whilst removing the contents of column A.

I've tried various pieces of code but run into Debug mode!

Thanks, Rob





  #4   Report Post  
Posted to microsoft.public.excel.programming
external usenet poster
 
Posts: 11,123
Default Loop column A and delete and move on condition

Hi Rob

Try this one for the activesheet
But If you have a cell with two '' in it it will also copy the cell to the C column

Sub Example()
Dim Lrow As Long
Dim CalcMode As Long
Dim StartRow As Long
Dim EndRow As Long
With Application
CalcMode = .Calculation
.Calculation = xlCalculationManual
.ScreenUpdating = False
End With

With ActiveSheet
.DisplayPageBreaks = False
StartRow = 1
EndRow = 500
For Lrow = EndRow To StartRow Step -1
If IsError(.Cells(Lrow, "A").Value) Then
'Do nothing, This avoid a error if there is a error in the cell
ElseIf Len(.Cells(Lrow, "A").Value) = 0 Then
.Cells(Lrow, "A").ClearContents
Else
.Cells(Lrow, "C").Value = .Cells(Lrow, "A").Value
End If
Next
End With
With Application
.ScreenUpdating = True
.Calculation = CalcMode
End With
End Sub


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



"Rob" wrote in message ...
Ron,

Because the apostrophes are set by a previous routine, there will only be two tests: firstly whether the cell appears empty but
has an apostrophe or whether there is some text.

I'm really interested in moving the text from column A to CO but can't just copy and paste as there is other contents in column
CO.

Thanks, Rob

"Ron de Bruin" wrote in message ...
If you have two '' in a cell Len will count 1.
What do you do then?


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



"Rob" wrote in message ...
Hi,
I'm trying to loop through cells in column A (say rows 1 to 500) and if the length of contents is 0, clear contents as there
will be apostrophes in the cells. If on the other hand the length of contents is greater than 0, I want to place the contents
from column A in column C of the same row, whilst removing the contents of column A.

I've tried various pieces of code but run into Debug mode!

Thanks, Rob







  #5   Report Post  
Posted to microsoft.public.excel.programming
Rob Rob is offline
external usenet poster
 
Posts: 234
Default Loop column A and delete and move on condition

Ron,

Thanks for this, I'd been trying with OffSet and failing miserably.

Regards, Rob

"Ron de Bruin" wrote in message
...
Hi Rob

Try this one for the activesheet
But If you have a cell with two '' in it it will also copy the cell to the
C column

Sub Example()
Dim Lrow As Long
Dim CalcMode As Long
Dim StartRow As Long
Dim EndRow As Long
With Application
CalcMode = .Calculation
.Calculation = xlCalculationManual
.ScreenUpdating = False
End With

With ActiveSheet
.DisplayPageBreaks = False
StartRow = 1
EndRow = 500
For Lrow = EndRow To StartRow Step -1
If IsError(.Cells(Lrow, "A").Value) Then
'Do nothing, This avoid a error if there is a error in the
cell
ElseIf Len(.Cells(Lrow, "A").Value) = 0 Then
.Cells(Lrow, "A").ClearContents
Else
.Cells(Lrow, "C").Value = .Cells(Lrow, "A").Value
End If
Next
End With
With Application
.ScreenUpdating = True
.Calculation = CalcMode
End With
End Sub


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



"Rob" wrote in message
...
Ron,

Because the apostrophes are set by a previous routine, there will only be
two tests: firstly whether the cell appears empty but has an apostrophe
or whether there is some text.

I'm really interested in moving the text from column A to CO but can't
just copy and paste as there is other contents in column CO.

Thanks, Rob

"Ron de Bruin" wrote in message
...
If you have two '' in a cell Len will count 1.
What do you do then?


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



"Rob" wrote in message
...
Hi,
I'm trying to loop through cells in column A (say rows 1 to 500) and if
the length of contents is 0, clear contents as there will be
apostrophes in the cells. If on the other hand the length of contents
is greater than 0, I want to place the contents from column A in column
C of the same row, whilst removing the contents of column A.

I've tried various pieces of code but run into Debug mode!

Thanks, Rob











  #6   Report Post  
Posted to microsoft.public.excel.programming
external usenet poster
 
Posts: 11,123
Default Loop column A and delete and move on condition

In this example you can use the Offset like this

.Cells(Lrow, "A").Offset(0, 2).Value = .Cells(Lrow, "A").Value


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



"Rob" wrote in message ...
Ron,

Thanks for this, I'd been trying with OffSet and failing miserably.

Regards, Rob

"Ron de Bruin" wrote in message ...
Hi Rob

Try this one for the activesheet
But If you have a cell with two '' in it it will also copy the cell to the C column

Sub Example()
Dim Lrow As Long
Dim CalcMode As Long
Dim StartRow As Long
Dim EndRow As Long
With Application
CalcMode = .Calculation
.Calculation = xlCalculationManual
.ScreenUpdating = False
End With

With ActiveSheet
.DisplayPageBreaks = False
StartRow = 1
EndRow = 500
For Lrow = EndRow To StartRow Step -1
If IsError(.Cells(Lrow, "A").Value) Then
'Do nothing, This avoid a error if there is a error in the cell
ElseIf Len(.Cells(Lrow, "A").Value) = 0 Then
.Cells(Lrow, "A").ClearContents
Else
.Cells(Lrow, "C").Value = .Cells(Lrow, "A").Value
End If
Next
End With
With Application
.ScreenUpdating = True
.Calculation = CalcMode
End With
End Sub


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



"Rob" wrote in message ...
Ron,

Because the apostrophes are set by a previous routine, there will only be two tests: firstly whether the cell appears empty but
has an apostrophe or whether there is some text.

I'm really interested in moving the text from column A to CO but can't just copy and paste as there is other contents in column
CO.

Thanks, Rob

"Ron de Bruin" wrote in message ...
If you have two '' in a cell Len will count 1.
What do you do then?


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



"Rob" wrote in message ...
Hi,
I'm trying to loop through cells in column A (say rows 1 to 500) and if the length of contents is 0, clear contents as there
will be apostrophes in the cells. If on the other hand the length of contents is greater than 0, I want to place the contents
from column A in column C of the same row, whilst removing the contents of column A.

I've tried various pieces of code but run into Debug mode!

Thanks, Rob











  #7   Report Post  
Posted to microsoft.public.excel.programming
external usenet poster
 
Posts: 27,285
Default Loop column A and delete and move on condition

To clear A when the value is moved, add the below line:

Sub Example()
Dim Lrow As Long
Dim CalcMode As Long
Dim StartRow As Long
Dim EndRow As Long
With Application
CalcMode = .Calculation
.Calculation = xlCalculationManual
.ScreenUpdating = False
End With

With ActiveSheet
.DisplayPageBreaks = False
StartRow = 1
EndRow = 500
For Lrow = EndRow To StartRow Step -1
If IsError(.Cells(Lrow, "A").Value) Then
'Do nothing, This avoid a error if there is a error in the
cell
ElseIf Len(.Cells(Lrow, "A").Value) = 0 Then
.Cells(Lrow, "A").ClearContents
Else
.Cells(Lrow, "C").Value = .Cells(Lrow, "A").Value
.Cells(Lrow, "A").ClearContents ' <=== added line
End If
Next
End With
With Application
.ScreenUpdating = True
.Calculation = CalcMode
End With
End Sub

--
Regards,
Tom Ogilvy


"Ron de Bruin" wrote in message
...
Hi Rob

Try this one for the activesheet
But If you have a cell with two '' in it it will also copy the cell to the

C column

Sub Example()
Dim Lrow As Long
Dim CalcMode As Long
Dim StartRow As Long
Dim EndRow As Long
With Application
CalcMode = .Calculation
.Calculation = xlCalculationManual
.ScreenUpdating = False
End With

With ActiveSheet
.DisplayPageBreaks = False
StartRow = 1
EndRow = 500
For Lrow = EndRow To StartRow Step -1
If IsError(.Cells(Lrow, "A").Value) Then
'Do nothing, This avoid a error if there is a error in the

cell
ElseIf Len(.Cells(Lrow, "A").Value) = 0 Then
.Cells(Lrow, "A").ClearContents
Else
.Cells(Lrow, "C").Value = .Cells(Lrow, "A").Value
End If
Next
End With
With Application
.ScreenUpdating = True
.Calculation = CalcMode
End With
End Sub


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



"Rob" wrote in message

...
Ron,

Because the apostrophes are set by a previous routine, there will only

be two tests: firstly whether the cell appears empty but
has an apostrophe or whether there is some text.

I'm really interested in moving the text from column A to CO but can't

just copy and paste as there is other contents in column
CO.

Thanks, Rob

"Ron de Bruin" wrote in message

...
If you have two '' in a cell Len will count 1.
What do you do then?


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



"Rob" wrote in message

...
Hi,
I'm trying to loop through cells in column A (say rows 1 to 500) and

if the length of contents is 0, clear contents as there
will be apostrophes in the cells. If on the other hand the length of

contents is greater than 0, I want to place the contents
from column A in column C of the same row, whilst removing the

contents of column A.

I've tried various pieces of code but run into Debug mode!

Thanks, Rob









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
move column on condition JICDB Excel Worksheet Functions 3 August 28th 06 11:38 PM
move from one column to another after a set condition BAZZA Excel Worksheet Functions 4 September 13th 05 12:45 PM
how do i move from one column to another after a set condition BAZZA Excel Worksheet Functions 0 September 13th 05 11:44 AM
Loop until a condition is False matt_steer[_3_] Excel Programming 1 May 18th 04 03:41 PM
two-condition loop Jamie Martin[_2_] Excel Programming 0 October 6th 03 11:47 PM


All times are GMT +1. The time now is 11:58 PM.

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"