Hirdetés

Keresés

Új hozzászólás Aktív témák

  • slashing

    senior tag

    válasz mdk01 #22533 üzenetére

    találtam egy ilyet:
    de csak 1 cellával működik viszont úgy néz ki hogy mindegy melyik két kijelölt cellán futtatod a makrót. Swap cell kulcsszóval keresgélj hátha van jobb is

    Sub Swap2Values()
    Dim Value1 As Range, Value2 As Range
    Dim TempValue1 As String, TempValue2 As String

    If Selection.Cells.Count > 2 Or Selection.Cells.Count < 2 Then
    MsgBox "Please select only 2 cells. For other options check back soon!"
    End
    End If

    If Selection.Areas.Count > 1 Then
    Set Value1 = Selection.Areas(1).Cells(1, 1)
    Set Value2 = Selection.Areas(2).Cells(1, 1)
    ElseIf Selection.Rows.Count > Selection.Columns.Count Then
    Set Value1 = Selection.Range("A1")
    Set Value2 = Selection.Range("A2")
    Else
    Set Value1 = Selection.Range("A1")
    Set Value2 = Selection.Range("B1")
    End If
    TempValue1 = Value1
    TempValue2 = Value2
    Value1 = TempValue2
    Value2 = TempValue1
    End Sub

Új hozzászólás Aktív témák