RE: Macro that deletes every third row....+



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


.



Relevant Pages

  • Re: Out of Control File Size
    ... you go to different sheets or cells and can speed things up by a factor of 30 ... Excel is trying to recalculate all dependent values based on the new value ... "Dawg House Inc" wrote: ... Private Sub wclearbutton_Click ...
    (microsoft.public.excel.programming)
  • Re: Creating a tick by clicking a cell
    ... like...make a certain range of cells so that you can only insert the right ... Private Sub Worksheet_BeforeRightClick(ByVal Target As Range, Cancel As Boolean) ... Dim res As Variant ...
    (microsoft.public.excel.misc)
  • RE: Combining multiple IF statements
    ... Usually date will not work if the cells are not in date format. ... within this same macro id like to add many additional statements like ... Sub dr2() ...
    (microsoft.public.excel.programming)
  • Re: REPSOT?? Sub Worksheet_Change(ByVal Target As Range)
    ... Private Sub Workbook_SheetChange(ByVal Sh As Object, ByVal Target As Range) ... will not work properly if the worksheet is protected even though the cells ... They have to run another macro when they are done changing anything anyway. ...
    (microsoft.public.excel.misc)
  • Re: how to delete a row in excel with a specific word using visual basic
    ... Sub the beginning of a macro, ... The variable Rng is a Range of cells. ... Rng.Count is a count of items in a collection of cells named Rng. ... End Sub the end of the macro. ...
    (microsoft.public.excel.misc)

Loading