Reply
 
LinkBack Thread Tools Search this Thread Display Modes
  #1   Report Post  
Dave Peterson
 
Posts: n/a
Default

Even if you insert more than one row, this just adds 110 to the value in that
original cell.

Option Explicit
Sub Macro99()
Dim numRows As Long
Dim iRow As Long
Dim LastRow As Long
Dim FirstRow As Long

numRows = Application.InputBox("How many Rows", Type:=1)

If numRows < 1 Then Exit Sub

Application.ScreenUpdating = False
With ActiveSheet
FirstRow = 5 '<--
LastRow = .Cells(.Rows.Count, "A").End(xlUp).Row

For iRow = LastRow To FirstRow Step -1
.Rows(iRow + 1).Resize(numRows).Insert
.Rows(iRow).Copy _
Destination:=.Rows(iRow + 1).Resize(numRows)
If IsNumeric(.Cells(iRow, "D").Value) Then
.Cells(iRow + 1, "D").Resize(numRows).Value _
= .Cells(iRow, "D").Value + 110
End If
'On Error Resume Next
'.Rows(iRow + ).Resize(numRows)
'.Cells.SpecialCells(xlCellTypeConstants).ClearCon tents
'On Error GoTo 0
Next iRow
End With
Application.ScreenUpdating = True
End Sub

sloanranger wrote:

i will only ever need to insert one row so d11=233 is correct

Lee Sloan


--

Dave Peterson
  #2   Report Post  
sloanranger
 
Posts: n/a
Default

Works a treat, thanks very much

Lee Sloan

  #3   Report Post  
sloanranger
 
Posts: n/a
Default

I have one more request,

i need to expand on the macro you wrote, this time can you make it turn
column X into a colour based on a number in column W

the colours i need are red, blue, yellow and green and the are
determined by the numbers 4,3,2 and 1 respectively.

example

X5=35mv
X6=70ml
X7=35ml
X8=70mv

dont worry about what X contain, but they must stay (they are the
result of a formula)

and

W5=4
W6=3
W7=2
W8=1

therefore X5 colorindex should be red, X6 should be blue, X7 should be
yellow and X8 should be green

and all this needs to be applied before the insert and copy loop starts

Hope you can help

Lee Sloan

  #4   Report Post  
Dave Peterson
 
Posts: n/a
Default

Just the new rows?

You'll have to record a macro to find the colors you want to use--I just used 4,
3, 2, 1 (Not close to what you want--but there are lots of shades of green.)

Option Explicit
Sub Macro99()
Dim numRows As Long
Dim iRow As Long
Dim LastRow As Long
Dim FirstRow As Long
Dim myColorIndex As Long

numRows = Application.InputBox("How many Rows", Type:=1)

If numRows < 1 Then Exit Sub

Application.ScreenUpdating = False
With ActiveSheet
FirstRow = 5 '<--
LastRow = .Cells(.Rows.Count, "A").End(xlUp).Row

For iRow = LastRow To FirstRow Step -1
.Rows(iRow + 1).Resize(numRows).Insert
.Rows(iRow).Copy _
Destination:=.Rows(iRow + 1).Resize(numRows)
If IsNumeric(.Cells(iRow, "D").Value) Then
.Cells(iRow + 1, "D").Resize(numRows).Value _
= .Cells(iRow, "D").Value + 110
End If
Select Case .Cells(iRow, "W").Value
Case Is = 1: myColorIndex = 4
Case Is = 2: myColorIndex = 3
Case Is = 3: myColorIndex = 2
Case Is = 4: myColorIndex = 1
Case Else
myColorIndex = xlNone
End Select
.Cells(iRow + 1, "x").Resize(numRows).Interior.ColorIndex _
= myColorIndex
Next iRow
End With
Application.ScreenUpdating = True
End Sub

sloanranger wrote:

I have one more request,

i need to expand on the macro you wrote, this time can you make it turn
column X into a colour based on a number in column W

the colours i need are red, blue, yellow and green and the are
determined by the numbers 4,3,2 and 1 respectively.

example

X5=35mv
X6=70ml
X7=35ml
X8=70mv

dont worry about what X contain, but they must stay (they are the
result of a formula)

and

W5=4
W6=3
W7=2
W8=1

therefore X5 colorindex should be red, X6 should be blue, X7 should be
yellow and X8 should be green

and all this needs to be applied before the insert and copy loop starts

Hope you can help

Lee Sloan


--

Dave Peterson
  #5   Report Post  
sloanranger
 
Posts: n/a
Default

are you asking if i only need this for the new rows?

If so the answer is no, i need the colours to be applied before the new
rows are inserted

Lee Sloan



  #6   Report Post  
sloanranger
 
Posts: n/a
Default

ive managed to resolve this one myself, i have move the select case
stuff before the isnumeric and it works.

Cheers

Lee SLoan

  #7   Report Post  
Dave Peterson
 
Posts: n/a
Default

Glad you got it working, but if all you did was move those sections around, then
that didn't change anything significant.



sloanranger wrote:

ive managed to resolve this one myself, i have move the select case
stuff before the isnumeric and it works.

Cheers

Lee SLoan


--

Dave Peterson
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
Activate a macro to insert a row and copy the formuals from the rows above to the blank row oil_driller Excel Discussion (Misc queries) 1 February 11th 05 03:30 PM
copy / paste selective rows Kenny Kendrena via OfficeKB.com Excel Discussion (Misc queries) 5 February 7th 05 12:55 PM
Copy conditional formatting across multiple rows? Gil Excel Discussion (Misc queries) 1 January 11th 05 11:27 AM
Copy Word table into Excel cell by cell hg Excel Discussion (Misc queries) 3 December 15th 04 04:43 PM
Paste rows of numbers from Word into single Excel cell BecG Excel Discussion (Misc queries) 1 December 8th 04 04:55 PM


All times are GMT +1. The time now is 03:42 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"