Reply
 
LinkBack Thread Tools Search this Thread Display Modes
  #1   Report Post  
Posted to microsoft.public.excel.programming
external usenet poster
 
Posts: 1
Default Tricky Tricky!


here what i got! :

A B C
1
2 1
3
4
5
6
7 2
8
9
10

I need a macro that will transform it to look like this! :

A B C
1
1440
2 1
3
4
5
6
1440
1440
7 2
8
9
10

So the macro will search in column C, and if there is a value 0 i
will insert new lines corresponding on the number he found in a C cel
(if C7=2, will insert two rows upward). After that i need the macro t
put the values 1440 in B cell of the new row inserted!

thanks

--
mha
-----------------------------------------------------------------------
mhax's Profile: http://www.excelforum.com/member.php...fo&userid=3645
View this thread: http://www.excelforum.com/showthread.php?threadid=56302

  #2   Report Post  
Posted to microsoft.public.excel.programming
external usenet poster
 
Posts: 1
Default Tricky Tricky!


or look at my file

+-------------------------------------------------------------------
|Filename: Classeur1.txt
|Download: http://www.excelforum.com/attachment.php?postid=5054
+-------------------------------------------------------------------

--
mha
-----------------------------------------------------------------------
mhax's Profile: http://www.excelforum.com/member.php...fo&userid=3645
View this thread: http://www.excelforum.com/showthread.php?threadid=56302

  #3   Report Post  
Posted to microsoft.public.excel.programming
external usenet poster
 
Posts: 860
Default Tricky Tricky!

Hi mhax,

Something like this should work:

Sub test()
Dim lLastRow As Long
Dim lCurrRow As Long
Dim vValue As Variant

Application.ScreenUpdating = False

With Worksheets("sheet1")
lLastRow = .Cells(.Rows.Count, 1).End(xlUp)

For lCurrRow = lLastRow To 1 Step -1
vValue = .Cells(lCurrRow, 3).Value
If Len(vValue) 0 And IsNumeric(vValue) Then
.Cells(lCurrRow, 1).Resize(vValue, _
1).EntireRow.Insert shift:=xlUp
.Cells(lCurrRow, 2).Resize(vValue, _
1).Value = 1440
End If
Next lCurrRow
End With

Application.ScreenUpdating = True
End Sub

There are more efficient ways of doing it if this is going to be recurring
task and you have thousands or tens of thousands of rows. But this should
be fairly quick.

--
Regards,

Jake Marx
www.longhead.com


[please keep replies in the newsgroup - email address unmonitored]

mhax wrote:
here what i got! :

A B C
1
2 1
3
4
5
6
7 2
8
9
10

I need a macro that will transform it to look like this! :

A B C
1
1440
2 1
3
4
5
6
1440
1440
7 2
8
9
10

So the macro will search in column C, and if there is a value 0 it
will insert new lines corresponding on the number he found in a C cell
(if C7=2, will insert two rows upward). After that i need the macro to
put the values 1440 in B cell of the new row inserted!

thanks!



  #4   Report Post  
Posted to microsoft.public.excel.programming
external usenet poster
 
Posts: 1
Default Tricky Tricky!


OMG!!!!!!!! THANKS YOU!!!!!!!! I will be able to finish my work tomorrow
finaly :D! You're doing a good job man! Have a good day!

Mhax

Jake Marx Wrote:
Hi mhax,

Something like this should work:

Sub test()
Dim lLastRow As Long
Dim lCurrRow As Long
Dim vValue As Variant

Application.ScreenUpdating = False

With Worksheets("sheet1")
lLastRow = .Cells(.Rows.Count, 1).End(xlUp)

For lCurrRow = lLastRow To 1 Step -1
vValue = .Cells(lCurrRow, 3).Value
If Len(vValue) 0 And IsNumeric(vValue) Then
.Cells(lCurrRow, 1).Resize(vValue, _
1).EntireRow.Insert shift:=xlUp
.Cells(lCurrRow, 2).Resize(vValue, _
1).Value = 1440
End If
Next lCurrRow
End With

Application.ScreenUpdating = True
End Sub

There are more efficient ways of doing it if this is going to be
recurring
task and you have thousands or tens of thousands of rows. But this
should
be fairly quick.

--
Regards,

Jake Marx
www.longhead.com


[please keep replies in the newsgroup - email address unmonitored]

mhax wrote:
here what i got! :

A B C
1
2 1
3
4
5
6
7 2
8
9
10

I need a macro that will transform it to look like this! :

A B C
1
1440
2 1
3
4
5
6
1440
1440
7 2
8
9
10

So the macro will search in column C, and if there is a value 0 it
will insert new lines corresponding on the number he found in a C

cell
(if C7=2, will insert two rows upward). After that i need the macro

to
put the values 1440 in B cell of the new row inserted!

thanks!



--
mhax
------------------------------------------------------------------------
mhax's Profile: http://www.excelforum.com/member.php...o&userid=36450
View this thread: http://www.excelforum.com/showthread...hreadid=563021

  #5   Report Post  
Posted to microsoft.public.excel.programming
external usenet poster
 
Posts: 860
Default Tricky Tricky!

mhax wrote:
OMG!!!!!!!! THANKS YOU!!!!!!!! I will be able to finish my work
tomorrow finaly :D! You're doing a good job man! Have a good day!


No problem - glad to help!

--
Regards,

Jake Marx
www.longhead.com


[please keep replies in the newsgroup - email address unmonitored]





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
Tricky one LondonJames Excel Worksheet Functions 1 January 17th 12 01:11 PM
This might be a little tricky...... nevi Excel Discussion (Misc queries) 2 June 17th 06 04:22 AM
Is it just me or is this tricky? philawde Excel Discussion (Misc queries) 7 November 23rd 05 03:58 PM
Help Please! (This one is a bit tricky) Dean Goodmen Excel Programming 2 February 25th 05 09:10 AM
Mmm tricky- but i'm sure someone out there can help! ali Excel Programming 1 December 6th 03 08:06 PM


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