27. maj 2014 - 07:44Der er
5 kommentarer og 1 løsning
Problem med VBA kode
Jeg skal have VBA koden til at lave en ny linje, med et linjenr. men når jeg köre denne får jeg bare 1 i alle linjerne. hvad gör jeg forkert????
Private Sub CommandButton2_Click() If txtBeskrivning.Value = "" Then MsgBox "skriv text här" txtBeskrivning.SetFocus Exit Sub End If If txtPlats.Value = "" Then MsgBox "skriv text här" txtPlats.SetFocus Exit Sub End If
Worksheets("Sheet1").Activate Range("B10").Select If Range("A4").Value = "" Then Range("A4").Activate Else Range("A4").CurrentRegion.Select ActiveCell.Offset(Selection.Rows.Count, 0).Activate End If With ActiveCell .Value = 1 + Count .Offset(0, 1).Value = txtPlats .Offset(0, 2).Value = txtBeskrivning End With
Unload Me End Sub
fra ecel filen jobnr. Place/ Machine Description 1 t1 test1 1 t2 test2 1 t3 test3
Det har du ret i värdien af count ändres ikke. Nu er det at min begränset viden om vba spiller ind, siden dette ikke er en loop hvordan får jeg den til at ändre sig?
Fik dette til at virke, men tror ikke de var sådan du mente.
Private Sub CommandButton2_Click() If txtBeskrivning.Value = "" Then MsgBox "skriv text här" txtBeskrivning.SetFocus Exit Sub End If If txtPlats.Value = "" Then MsgBox "skriv text här" txtPlats.SetFocus Exit Sub End If
Worksheets("Sheet1").Activate Range("C4").Select If Range("A4").Value = "" Then Range("A4").Activate Else
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.