Reply
 
LinkBack Thread Tools Search this Thread Display Modes
  #1   Report Post  
Posted to microsoft.public.excel.programming
external usenet poster
 
Posts: 76
Default How can Relative Cells/Ranges be Cleared when Rows are Inserted?

The code below copies 2 adjacent rows and inserts them either above or
below the 2 current rows (2 rows = 1 record). However, I need to
clear certain parts of the 2 newly inserted rows:

--contents of cols. D and E (absolute),
--contents of cols. AP to the end of all consecutive cols. with the
text "Activity" in row 12 (the ending col. is relative since the
number of activities will increase). "Activity" is inserted into each
of these cols. as labels in row 12.
--and the contents of all consectutive cols. with dates 'mm/dd/yy'
typed in row 12 (the starting col. is relative since new 'Activity'
cols. will be inserted through time). The ending col. can just be IV.

I've been playing around with range().clear, but cannot figure out how
to clear these separate ranges on the 2 separate rows.

=================

'Great code from Bernie Deitrick

Sub InsertBlockAboveOrBelow()
Dim myCell As Range
Dim newFName As String
Dim newLName As String

newFName = InputBox("What is the new first name?")
newLName = InputBox("What is the new last name?")

If Cells(ActiveCell.Row, 1).Value = "" Then
Set myCell = Cells(ActiveCell.Row, 1).End(xlUp)
Else
Set myCell = Cells(ActiveCell.Row, 1)
End If

With myCell.Resize(2).EntireRow
If MsgBox("Above = ""Yes"", Below = ""No""", vbYesNo) = vbYes Then
.Copy
.Insert
myCell.Offset(-2).Value = newFName
myCell.Offset(-2,1).Value = newLName
Else
.Copy
.Offset(4).Insert
myCell.Offset(2).Value = newFName
myCell.Offset(2,1).Value = newLName
End If
End With

Application.CutCopyMode = False
End Sub

Thanks,
Eric

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
Insert rows and keep merged cells in the inserted row Buggelsgaard Excel Discussion (Misc queries) 1 August 27th 08 06:33 PM
Change colour of cells when content is altered/changed BUT NOT TO INSERTED OR DELETED ROWS Martin ©¿©¬ @nohere.net Excel Discussion (Misc queries) 3 April 12th 08 05:13 PM
Relative Ranges - Multiple Cells Helen Excel Programming 1 July 12th 06 12:55 PM
Inserting/Deleting Rows when values are added /cleared teresa Excel Programming 1 January 23rd 05 03:03 PM
select ranges of cells relative to location and then paste Buffyslay Excel Programming 3 June 22nd 04 05:00 PM


All times are GMT +1. The time now is 12:47 AM.

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"