Ok, so the part that was supposed to be bold is
![]()
If Target = 0 Then
Ok, so the part that was supposed to be bold is
![]()
If Target = 0 Then
You said:
But, theni end up with little holes in the list whenever i finish a task because what my macroes does is whenever a job is marked as done on the list it moves that job to sheet2
So, which sheet gets the rows moved down? Sheet2 with its list of completed jobs do that the latest job is at the top?I'd like to have a macro that shifts all the rows 1 down whenever a job is completed
Or, the list on sheet1? It seems to me that if you move a record from sheet1 to sheet2 leaving a hole in sheet1, then you would want to move the tasks below the hole UP one to fill that hole, not down one.
However, prefix , you did not provide any sample tasks for either sheet.
Ben Van Johnson
It sounds like you want row 26 to be stationary.
If a row (or non-whole row cells?) were inserted above that, you would want the old row 25 to become the new 27 as everything else shifts down.
Is that the situation?
_
...How to Cross-post politely...
..Wrap code by selecting the code and clicking the # or read this. Thank you.
You could put this in the sheet's code module. Then if a cell (in a discreet location) had the formula =ROWS(1:65536), the Calculate event would be triggered by the inserting or deleting of a cell.
In the attached Row 5 is the stationary row.![]()
Private Sub Worksheet_Calculate() Dim combinedRange As Range, oneArea As Range, homeRange As Range Dim colNum As Long Const stationaryRow As Long = 5 Const namePrefix As String = "stationaryCell" Const lowColumn As Long = 1 Const highColumn As Long = 50 With Application .ScreenUpdating = False .Calculation = xlManual .EnableEvents = False End With On Error GoTo CreateCellName Set combinedRange = ThisWorkbook.Names(namePrefix & lowColumn).RefersToRange For colNum = lowColumn To highColumn With ThisWorkbook.Names(namePrefix & colNum).RefersToRange Set combinedRange = Application.Union(combinedRange, .Cells) End With Next colNum On Error GoTo 0 For Each oneArea In combinedRange.Areas Set homeRange = oneArea.EntireColumn.Rows(stationaryRow) Select Case oneArea.Row Case Is < stationaryRow: Rem some cell above is deleted homeRange.Cut oneArea.Insert shift:=xlDown Case Is > stationaryRow: Rem some cell was inserted oneArea.Cut homeRange.Insert shift:=xlDown End Select Next oneArea With Application .CutCopyMode = False .Calculation = xlAutomatic .EnableEvents = True .ScreenUpdating = True End With Exit Sub CreateCellName: If Err <> 1004 Then GoTo Halt If colNum < 1 Then colNum = 1 ThisWorkbook.Sheets("Sheet1").Cells(stationaryRow, colNum).Name = namePrefix & colNum ThisWorkbook.Names(namePrefix & colNum).Visible = False Err.Clear Resume Halt: Err.Clear On Error GoTo 0 With Application .Calculation = xlAutomatic .EnableEvents = True .ScreenUpdating = True End With End Sub
The action is restricted to columns 1-50 of that row, but the constants can be altered to meet your situation.
For example, you want stationaryRow to be 25
Edit: One line should be changed.
Last edited by mikerickson; 01-25-2010 at 10:07 AM.
Awesome! Thanks heaps for that answer :-)
Wish there was a feature for this in Excel where you could ignore a certain row from Shift:=xlDown. Oh well, this code you wrote is certainly very flexible and it can probably be implemented into any existing sheetagain, Thank you for spending your time to help me. Rep has been added
Hate to ask but does anyone know the answer to my second question too? My workbook won't run without solving that particular issue.
To recap i have the code i want but it seems to be working outside its range from what i can understand, this is the code:
Whenever i click a button i made that runs this macro:![]()
Private Sub Worksheet_SelectionChange(ByVal Target As Range) If Intersect(Target, Range("A15:A77,L15:L77")) Is Nothing Then Exit Sub If Target = 0 Then Target.NumberFormat = "dd.mm.yy" Target.Value = Date End If End Sub
The RemovePic2 macro code is:![]()
Sub Row2Copy() Dim Answer As String Dim MyNote As String 'Place your text here MyNote = "Vil du flytte raden til ferdige oppgaver?" 'Display MessageBox Answer = MsgBox(MyNote, vbQuestion + vbYesNo, "???") If Answer = vbNo Then 'Code for No button Press Exit Sub Else 'Code for Yes button Press Sheets("Aktive Oppgaver").Activate Range("A16:L16").Select Selection.Copy Sheets("Ferdige Oppgaver").Activate Rows("15:15").Select Selection.Insert Shift:=xlDown Sheets("Aktive Oppgaver").Activate Range("K16").Select Selection.EntireRow.Select Selection.ClearContents Call RemovePic2 End If End Sub
I can only assume something here is messing with the Timestamp code.![]()
Sub RemovePic2() Dim Sh As Shape With Worksheets("Aktive Oppgaver") For Each Sh In .Shapes If Not Application.Intersect(Sh.TopLeftCell, .Range("K16:K16")) Is Nothing Then If Sh.Type = msoPicture Then Sh.Delete End If Next Sh End With End Sub
When i run the code i just pasted i get: Run time error 13 type mismatch and when i click debug i'm pointed to:
Inside the Timestamp function.![]()
If Target = 0 Then
Anyone got any ideas?
I am trying to get this to work so far it does not do what i want.. I am posting my entire workbook since it does not contain any sensitive information.
Whenever i insert a row stationary row 26 becomes row 27 and whenever my macro does selection.clearcontent and a gap appears between lines(you'll see what i mean in the worksheet) it does not shift them in the proper order..
...Once again i failed to upload a file attachment to this post and had to resort to alternative file hosting, hopefully this will be ok with whoever writes an answer.. I would use excelforum if i could but it just gives me errors.. and no, the xls is not above 1mb :P
Anyway, here's the workbook just type in the captcha and hit Free Download..
http://ulozto.net/3797153/tiltakslistev3.xls
Thanks!
There are currently 1 users browsing this thread. (0 members and 1 guests)
Bookmarks