Jeg har en macro der ændre celle farve. Den virker os fint nok, men vil gerne have den til at os ændre farve til cellen til højre.
lad os sige: A1 dobbelt klikker jeg på. Så skal B1 os ændre farve.
Koden jeg bruger pt.
Private Sub Worksheet_BeforeDoubleClick(ByVal Target As Excel.Range, Cancel As Boolean) If Application.Intersect(Target, Range("D8:AC29")) Is Nothing Then Exit Sub End If ' If the cell is clear If Target.Interior.ColorIndex = xlNone Then ' Then change the background color to red Target.Interior.ColorIndex = 3 ' Else if the cell background color is red ElseIf Target.Interior.ColorIndex = 3 Then ' Then clear the background Target.Interior.ColorIndex = xlNone End If ' This is to prevent the cell from being edited when double-clicked Cancel = True End Sub
Hos Computerworld it-jobbank er vi stolte af at fortsætte det gode partnerskab med folkene bag IT-DAY – efter vores mening Danmarks bedste karrieremesse for unge og erfarne it-kandidater.
Private Sub Worksheet_BeforeDoubleClick(ByVal Target As Excel.Range, Cancel As Boolean) If Application.Intersect(Target, Range("D8:AC29")) Is Nothing Then Exit Sub End If ' If the cell is clear If Target.Interior.ColorIndex = xlNone Then ' Then change the background color to red Target.Interior.ColorIndex = 3 Target.Offset(0, 1).Interior.ColorIndex = 3 ' Else if the cell background color is red ElseIf Target.Interior.ColorIndex = 3 Then ' Then clear the background Target.Interior.ColorIndex = xlNone Target.Offset(0, 1).Interior.ColorIndex = xlNone End If ' This is to prevent the cell from being edited when double-clicked Cancel = True End Sub
Synes godt om
Ny brugerNybegynder
Din løsning...
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.