View Single Post
  #2   Report Post  
Posted to microsoft.public.excel.programming
Tom Ogilvy Tom Ogilvy is offline
external usenet poster
 
Posts: 27,285
Default Reduce a value by spliting the data

Hard to tell what you are doing, but maybe this will help. I would test it
on something much less than F4:J152
Sub checksize()
Range("f4:J152").Select
For Each Item In Selection
Do Until Item <= 40
With Item
Range("A" & Item.Row & ":" & "v" & Item.Row).Select
Item.Value = Item.Value - 35
Selection.Copy
Selection.Insert Shift:=xlDown
Item.Value = 35
MsgBox ("Item " & Item.Row - 3 & " ~ Is too big, it has been split in
sections!")
End With
Loop
Next Item
End Sub

--
Regards,
Tom Ogilvy


"Kev" wrote in message
. uk...
Hi
I'm trying to get a sheet to work, It resizes the row's depending on a
value in a range, but to prevent errors happening
I want to split the item by coping & posting the data and altering
the value. I've got this code to work but how do I get it to carry on
untill the values are below 40, currently it works for a value of 75

kev

Sub checksize()
Range("f4:J152").Select
For Each Item In Selection

If Item = 40 Then
With Item
Range("A" & Item.Row & ":" & "v" & Item.Row).Select
Item.Value = Item.Value - 35
Selection.Copy
Selection.Insert Shift:=xlDown
Item.Value = 35
MsgBox ("Item " & Item.Row - 3 & " ~ Is too big, it has
been split in sections!")
End With


End If



Next Item
End Sub