RE: Macro that deletes every third row....+
- From: JLatham <JLatham@xxxxxxxxxxxxxxxxxxxxxxxxx>
- Date: Mon, 26 Jun 2006 14:18:02 -0700
Here's a second segment of code that will take care of both part 2 and the
move 12
spaces of cells in column B into C.
Sub MoveEveryOtherCellsData(LastRowNowInUse As Long)
'
'now to copy every other cell content from A2, A4 over
'to column B
Dim AOffset As Long
Dim BOffset As Long
Dim strTest As String
AOffset = 0 ' initialize to zero
BOffset = 0 ' initialize to zero
Range("A2").Select
Do Until BOffset > LastRowNowInUse
Range("B1").Offset(BOffset, 0) = _
Range("A2").Offset(AOffset, 0)
'and while we are at it, take the 1st 12 characters of entry just
'moved into column B and put them into column C
On Error Resume Next
strTest = Range("B1").Offset(BOffset, 0)
If Err <> 0 Then
Err.Clear
Range("B1").Offset(BOffset, 1) = _
Range("B1").Offset(BOffset, 0)
Else
If Len(strTest) > 11 Then
Range("B1").Offset(BOffset, 1) = _
Left(Range("B1").Offset(BOffset, 0), 12)
Else
Range("B1").Offset(BOffset, 1) = _
Range("B1").Offset(BOffset, 0)
End If
End If
On Error GoTo 0 ' clear error trapping
AOffset = AOffset + 2
BOffset = BOffset + 1
Loop
End Sub
insert this line just before the Application.ScreenUpdating = True statement
in the previous routine:
MoveEveryOtherCellsData LastRowNowInUse
and the first routine will call the second one before finishing up.
"ajjag" wrote:
.
I am fairly new to creating macros and am stuck on something...
Here is the sequence that I want to follow:
1. I need to delete every third starting at row 3 (3,6,9,12,etc) and
move information up
2. Cut and paste every other cell starting at A2......A300 i.e.
(2,4,6,etc) after those cells from part 1 have been moved up and moved
over to column B starting at B1 with no spaces between the information
3. Then the newly blanks cells in column A need to be moved up....
Is it then possible to take the first 12 spaces of the cells in column
B and move them over to column C?
Sorry if I put too much for a first post but I am stuck.
Thanks to anyone who can help
--
ajjag
------------------------------------------------------------------------
ajjag's Profile: http://www.excelforum.com/member.php?action=getinfo&userid=35799
View this thread: http://www.excelforum.com/showthread.php?threadid=555717
- Follow-Ups:
- Re: Macro that deletes every third row....+
- From: ajjag
- Re: Macro that deletes every third row....+
- References:
- Macro that deletes every third row....+
- From: ajjag
- Macro that deletes every third row....+
- Prev by Date: Re: Using vlookup when referencing text
- Next by Date: Re: fomula needed to find the "new" time, for example if
- Previous by thread: Macro that deletes every third row....+
- Next by thread: Re: Macro that deletes every third row....+
- Index(es):
Relevant Pages
|
Loading