Thema Datum  Von Nutzer Rating
Antwort
Rot VBA EXCEL DATA Validation
11.09.2023 14:54:11 Nouman
NotSolved
11.09.2023 16:51:24 Gast31769
NotSolved
12.09.2023 09:40:15 Gast88628
NotSolved
11.09.2023 17:09:48 Gast54077
NotSolved
11.09.2023 18:52:56 Gast49808
NotSolved
12.09.2023 15:32:32 Gast31769
NotSolved
12.09.2023 20:17:45 Gast11037
NotSolved

Ansicht des Beitrags:
Von:
Nouman
Datum:
11.09.2023 14:54:11
Views:
300
Rating: Antwort:
  Ja
Thema:
VBA EXCEL DATA Validation

 

=IF(EXACT(W23,"Evaluate"),IF(COUNTBLANK($F23:$J23)<5,LOOKUP("X",$F23:$J23,$F$20:$J$20),0),0) 

I am working on a rating Interpretation scale. This is the formula that I have applied to Excel Worksheet. Inside the Range F23 to J33, I have used the Data Validation rule that allows the user to select "X" It basically looks through a range of F23 to J33 and if "X" is seen in any row, it goes back to F20:J20 where the values are stored from 1 to 5. Normally this formulae is working fine but when I try to incorporate it into VBA, it doesn't show any value. This is the code that I am using. Please let me know if I am doing it right. 

Private Sub Worksheet_Change(ByVal Target As Range)
    Dim ws As Worksheet
    Dim ValidationRange As Range
    Dim Cell As Range

    ' Define the worksheet
    Set ws = ThisWorkbook.Sheets("Sheet 1")

    ' Define the validation range (F23:J33)
    Set ValidationRange = ws.Range("F23:J33")

    ' Check if the change occurred within the ValidationRange
    If Not Intersect(Target, ValidationRange) Is Nothing Then
        Application.EnableEvents = False ' Disable events to prevent re-triggering
        For Each Cell In Target.Cells
            If Cell.Value = "X" Then
                ' Get the corresponding value from row 20 (F20 to J20)
                Dim ValueToDisplay As Variant
                ValueToDisplay = ws.Cells(20, Cell.Column).Value
                ' Update the value in column AF in the same row
                ws.Cells(Cell.Row, "AF").Value = ValueToDisplay
            End If
        Next Cell
        Application.EnableEvents = True ' Re-enable events
    End If
End Sub

 


 


Ihre Antwort
  • Bitte beschreiben Sie Ihr Problem möglichst ausführlich. (Wichtige Info z.B.: Office Version, Betriebssystem, Wo genau kommen Sie nicht weiter)
  • Bitte helfen Sie ebenfalls wenn Ihnen geholfen werden konnte und markieren Sie Ihre Anfrage als erledigt (Klick auf Häckchen)
  • Bei Crossposting, entsprechende Links auf andere Forenbeiträge beifügen / nachtragen
  • Codeschnipsel am besten über den Code-Button im Text-Editor einfügen
  • Die Angabe der Emailadresse ist freiwillig und wird nur verwendet, um Sie bei Antworten auf Ihren Beitrag zu benachrichtigen
Thema: Name: Email:



  • Bitte beschreiben Sie Ihr Problem möglichst ausführlich. (Wichtige Info z.B.: Office Version, Betriebssystem, Wo genau kommen Sie nicht weiter)
  • Bitte helfen Sie ebenfalls wenn Ihnen geholfen werden konnte und markieren Sie Ihre Anfrage als erledigt (Klick auf Häckchen)
  • Bei Crossposting, entsprechende Links auf andere Forenbeiträge beifügen / nachtragen
  • Codeschnipsel am besten über den Code-Button im Text-Editor einfügen
  • Die Angabe der Emailadresse ist freiwillig und wird nur verwendet, um Sie bei Antworten auf Ihren Beitrag zu benachrichtigen

Thema Datum  Von Nutzer Rating
Antwort
Rot VBA EXCEL DATA Validation
11.09.2023 14:54:11 Nouman
NotSolved
11.09.2023 16:51:24 Gast31769
NotSolved
12.09.2023 09:40:15 Gast88628
NotSolved
11.09.2023 17:09:48 Gast54077
NotSolved
11.09.2023 18:52:56 Gast49808
NotSolved
12.09.2023 15:32:32 Gast31769
NotSolved
12.09.2023 20:17:45 Gast11037
NotSolved