Selve koden kan se slik ut...men hva skal trigge macroen?
Public Sub test() Dim vdB() As Variant If Cells(11, 3).Value = "HT" Then vdB() = Cells(11, 3).Resize(1, 4).Value Sheets("HT").Select Cells(1, 1).Resize(1, 4) = vdB Rows(1).Insert End If End Sub
Kan man ikke lave noget så de køre sammen med HT Marco
____________________ Private Sub Worksheet_SelectionChange(ByVal Target As Range) Dim vTmp() As Variant If Target.Address = "$F$5" Then Call Add_vognløb End If End Sub _______________________
Private Sub Worksheet_SelectionChange(ByVal Target As Range) Dim vTmp() As Variant If Target.Address = "$F$5" Then Call Add_vognløb If Cells(11,3).Value = "HT" Then Call HT End If End Sub
Private Sub Worksheet_SelectionChange(ByVal Target As Range) Dim vTmp() As Variant If Target.Address = "$F$5" Then If Cells(11,3).Value = "HT" Then Call HT Call Add_vognløb End If End Sub
Hva med denne, da vil alt som kommer inn i regnearket få store bokstave
Private Sub Worksheet_SelectionChange(ByVal Target As Range) Target.Value = UCase(Target.Value )) Dim vTmp() As Variant If Target.Address = "$F$5" Then Call Add_vognløb End If End Sub
Hvis dette kun gjelder ht Ht eller hT, er dette en mulighet.
Private Sub Worksheet_SelectionChange(ByVal Target As Range) Dim vTmp() As Variant If UCase(Target.Value )) = "HT" Then Target.Value = "HT" If Target.Address = "$F$5" Then Call Add_vognløb End If End Sub
prøver igjen:-) Etter som jeg ikke vet hvilke variant du skal benytte, kommer det 3 eksempler:
1) Private Sub Worksheet_SelectionChange(ByVal Target As Range) Dim vTmp() As Variant If UCase(Target.Value )) = "HT" Then Target.Value = "HT" If Target.Address = "$F$5" Then Call Add_vognløb If Cells(11,3).Value = "HT" Then Call HT End If End Sub
2) Private Sub Worksheet_SelectionChange(ByVal Target As Range) Dim vTmp() As Variant If UCase(Target.Value )) = "HT" Then Target.Value = "HT" If Cells(11,3).Value = "HT" Then Call HT If Target.Address = "$F$5" Then Call Add_vognløb End If End Sub
3) Private Sub Worksheet_SelectionChange(ByVal Target As Range) Dim vTmp() As Variant If UCase(Target.Value )) = "HT" Then Target.Value = "HT" If Target.Address = "$F$5" Then Call Add_vognløb End If If Cells(11,3).Value = "HT" Then Call HT End Sub
Da har jeg tatt en titt på ditt flotte regneark! Kan du ikke bekrive hvordan "Vognsiden fungerer" Og hvordan du legger den ut på internett.
Jeg har teste ditt regneark med denne koden, den fungerer hos meg.
Private Sub Worksheet_SelectionChange(ByVal Target As Range) If Target.Address = Cells(5, 6).Address Then Target.Offset(, -3).Value = Trim(Target.Offset(, -3).Text) If UCase(Target.Offset(, -3).Value) = "HT" Then Target.Offset(, -3).Value = "HT" End If For Each c In Range(Cells(5, 3), Cells(5, 5)) If IsEmpty(c) Then Cells(5, 3).Select Exit Sub End If Next Cells(5, 6).FormulaR1C1 = "=now()" Call Add_vognløb If Cells(11, 3).Value = "HT" Then Call HT End If End Sub
jeg fant ingen HT i ditt regneark, benyttet derfor denne:
Public vdB() As Variant
Public Sub HT() With Worksheets("Vognløb") vdB = Range(.Cells(11, 3), .Cells(11, 6)) End With With Worksheets("HT") .Rows(2).Insert Range(.Cells(2, 1), .Cells(2, 4)) = vdB End With ActiveWorkbook.Save End Sub
jeg prøvde meg på vognløpet også, men den fungerer ikke helt, hvis ønskelig kan jeg se på det senere.
Sub Add_vognløb() With Worksheets("Vognløb") vdB = Range(.Cells(5, 3), .Cells(5, 6)) Range(.Cells(5, 3), .Cells(5, 6)).ClearContents .Cells(5, 3).Select .Rows(10).Insert Range(.Cells(10, 3), .Cells(10, 6)) = vdB End With With Worksheets("Printliste") .Rows(2).Insert Range(.Cells(2, 1), .Cells(2, 4)) = vdB End With ActiveWorkbook.Save End Sub
Sub Add_vognløb() With Worksheets("Vognløb") With Range(.Cells(5, 3), .Cells(5, 6)) vdB = .Value .ClearContents .Resize(1, 1).Select End With .Rows(11).Insert With Range(.Cells(11, 3), .Cells(11, 6)) .Value = vdB .Borders().LineStyle = xlContinuous .Interior.ColorIndex = xlNone End With End With With Worksheets("Printliste") .Rows(2).Insert Range(.Cells(2, 1), .Cells(2, 4)) = vdB End With ActiveWorkbook.Save End Sub
på vognløb skal man kunne adde nye som den gør med denne Private Sub Worksheet_SelectionChange(ByVal Target As Range) Dim vTmp() As Variant If Target.Address = "$F$5" Then Call Add_vognløb End If End Sub Ud over det skal den køre en ekstre macro hvis der står HT det gør den også men først efter man har addet en anden som ikke er HT.
Private Sub Worksheet_SelectionChange(ByVal Target As Range) Dim vTmp() As Variant If Target.Address = "$F$5" Then If Cells(11, 3).Value = "HT" Then Call HT Call Add_vognløb End If End Sub
Private Sub Worksheet_SelectionChange(ByVal Target As Range) If Target.Address = Cells(5, 6).Address Then Target.Offset(, -3).Value = Trim(Target.Offset(, -3).Text) If UCase(Target.Offset(, -3).Value) = "HT" Then Target.Offset(, -3).Value = "HT" End If For Each c In Range(Cells(5, 3), Cells(5, 5)) If IsEmpty(c) Then Cells(5, 3).Select Exit Sub End If Next Cells(5, 6).FormulaR1C1 = "=now()" Call Add_vognløb If vdB(1, 1) = "HT" Then Call HT End If End Sub
Public vdB() As Variant Sub Add_vognløb() With Worksheets("Vognløb") With Range(.Cells(5, 3), .Cells(5, 6)) vdB = .Value .ClearContents .Resize(1, 1).Select End With .Rows(11).Insert With Range(.Cells(11, 3), .Cells(11, 6)) .Value = vdB .Borders().LineStyle = xlContinuous .Interior.ColorIndex = xlNone End With End With With Worksheets("Printliste") .Rows(2).Insert Range(.Cells(2, 1), .Cells(2, 4)) = vdB End With ActiveWorkbook.Save End Sub
Public Sub HT() With Worksheets("HT") .Rows(2).Insert Range(.Cells(2, 1), .Cells(2, 4)) = vdB End With ActiveWorkbook.Save End Sub
det skal alt være et most at skrive noger i bemærkning denne setningen: For Each c In Range(Cells(5, 3), Cells(5, 5)) If IsEmpty(c) Then Cells(5, 3).Select Exit Sub End If Next Gjør at du ikke kommer videre før alle felter er fylt ut. Gjør et forsøk :-)
Private Sub Worksheet_SelectionChange(ByVal Target As Range) If Target.Address = Cells(5, 6).Address Then Target.Offset(, -3).Value = Trim(Target.Offset(, -3).Text) If UCase(Target.Offset(, -3).Value) = "HT" Then Target.Offset(, -3).Value = "HT" End If For Each c In Range(Cells(5, 3), Cells(5, 4)) If IsEmpty(c) Then Cells(5, 3).Select Exit Sub End If Next Cells(5, 6).FormulaR1C1 = "=now()" Call Add_vognløb If vdB(1, 1) = "HT" Then Call HT End If End Sub
vi gir oss ikke :-) nå blir det rammer både på print og HT Hvis du ønsker å ta bort rammene på den ene, skal du ta bort: .Borders().LineStyle = xlContinuous
Public vdB() As Variant Sub Add_vognløb() With Worksheets("Vognløb") With Range(.Cells(5, 3), .Cells(5, 6)) vdB = .Value .ClearContents .Resize(1, 1).Select End With .Rows(11).Insert With Range(.Cells(11, 3), .Cells(11, 6)) .Value = vdB .Borders().LineStyle = xlContinuous .Interior.ColorIndex = xlNone End With End With With Worksheets("Printliste") .Rows(2).Insert
With Range(.Cells(2, 1), .Cells(2, 4)) .Value = vdB .Borders().LineStyle = xlContinuous End With
End With ActiveWorkbook.Save End Sub
Public Sub HT() With Worksheets("HT") .Rows(2).Insert With Range(.Cells(2, 1), .Cells(2, 4)) .Value = vdB .Borders().LineStyle = xlContinuous End With End With ActiveWorkbook.Save End Sub
Tilladte BB-code-tags: [b]fed[/b] [i]kursiv[/i] [u]understreget[/u] Web- og emailadresser omdannes automatisk til links. Der sættes "nofollow" på alle links.