How to Prevent Paste on Data Validation cell in Microsoft Excel? Solved via VBA MACRO

Поделиться
HTML-код
  • Опубликовано: 7 ноя 2024

Комментарии • 50

  • @ExcelBasement
    @ExcelBasement  4 года назад +16

    Private Sub Worksheet_Change(ByVal Target As Range)
    Dim xValue As String
    Dim xCheck1 As String
    Dim xCheck2 As String
    If Target.Count > 1 Then
    Exit Sub
    End If
    Application.EnableEvents = False
    xValue = Target.Value
    On Error Resume Next
    xCheck1 = Target.Validation.InCellDropdown
    On Error GoTo 0
    Application.Undo
    On Error Resume Next
    xCheck2 = Target.Validation.InCellDropdown
    On Error GoTo 0
    If xCheck1 = xCheck2 Then
    Target = xValue
    Else
    MsgBox "No pasting allowed!"
    End If
    Application.EnableEvents = True
    End Sub

    • @akshaysrivastava7400
      @akshaysrivastava7400 2 года назад

      Thanks for this amazing code, it was really helpful for me

    • @redarrow6161
      @redarrow6161 2 года назад

      Where the path I should add this code thanks

    • @zafarsayeed3107
      @zafarsayeed3107 Год назад

      Great, but i have a problem, when I paste the value from left cell to right then this code is working, but when I paste the value from right cell to left then this code is not working.
      please provide the solution.:)

    • @yosef-yosef9414
      @yosef-yosef9414 Год назад

      Thank you SO much

    • @Santosh-jx3yf
      @Santosh-jx3yf 6 месяцев назад

      I have big issue when the user paste big data in same month format, but did not allow to paste.
      Only provide choose option .
      I want user can able to paste same month data in drop down. Unwanted entry need to be stop.

  • @davidatayureatazona1296
    @davidatayureatazona1296 3 года назад +3

    Thank you very much sir for your amazing presentation. I have however noticed that your approach only works when "CTRL+V" is used for pasting. However when I right-click and select the paste special value options, I am able to go around the macro restriction. Is there another option to prevent this from happening. Thank you

  • @JayPatel-zm9rn
    @JayPatel-zm9rn 4 года назад +4

    Hi, Great work but the problem I am facing is that I wants to allow users to paste date that is given in data validation. How do I do it? I want my team to edit any date that is not tomorrow.

  • @indrajeetdeka6954
    @indrajeetdeka6954 8 месяцев назад

    Hi
    If I have a cell with data validation list, and using VBA code if I want to select options from the drop-down list serially how can I do it?

  • @redhaakhund1271
    @redhaakhund1271 3 года назад

    Thank you brother Raheem for the video. I have question if you plz advise how to. I have two lists of employees with weekdays.
    If "Employee 1" worked on "Thursday" o "List 1", than, on "List 2" his should work on Normal day. Thanks and waiting your reply plz

  • @eriktamazyan5936
    @eriktamazyan5936 3 года назад +1

    Thank you very much, this helps me, thank you from Armenia!!!!

  • @LouieJamesR
    @LouieJamesR 2 года назад +2

    Thank you for this. Can we also have a code to prevent the person to copy the value from another workbook and paste it to this workbook? :)

    • @islandcontrol
      @islandcontrol Год назад

      Did you figure this out I have formatted my cell entries so as that they cannot be seen in either formula bar or the cell and just need them to not be able to copy and paste the cell value to enable full security of the data?

  • @abhisheksg292
    @abhisheksg292 Год назад

    Not finding Macro details in description. Please advice

  • @senthilprabhu7803
    @senthilprabhu7803 2 года назад

    HI the code is working but,
    IF a range is chosen, for this macro any data outside of the range cannot be pasted inside the range but within the selected range copy and paste is happening without any error message

  • @saifsudais
    @saifsudais 3 года назад

    Salam! I have a problem coding in Excel VBA, which needs your guidance. When executing a macro with the command button in Excel, an error occurs while copying and pasting the formula via VBA code.
    I want the VB code to run and the previous line formula to be pasted into the next line and the formula to be hidden and protected without any errors. While the rest of the cells remain unprotected for data entry.
    Can you guide me in this regard?

  • @basavanagoudaspatil6122
    @basavanagoudaspatil6122 2 года назад

    Hi,
    I want to allow copy paste of the data on a cell with data validation but upon paste, the data validation has to come up. By this way paste is also allowed and data validation is also protected. How do we do this

  • @8swarada
    @8swarada 3 года назад +1

    It Works!!...superb...thanks a ton!!!🙏🙏

  • @Ravi_s_malenadiga
    @Ravi_s_malenadiga 2 года назад

    How to do that in excel using vba macro option please make a video of that.

  • @diya471985
    @diya471985 3 года назад

    I tried this code, its working. But problem is if we copy entire column rule is not getting applied

  • @umarmukhtar1338
    @umarmukhtar1338 11 месяцев назад

    Vba code is not showing in description

  • @hiralchotaliya9070
    @hiralchotaliya9070 3 года назад

    No pasting allowed done. Not able type and change in macro enable cell.
    kindly suggest how to edit cell after prevent pasting?

  • @asimali5820
    @asimali5820 2 года назад

    Sir, Can you plz share a code to prevent user from copying value from another sheet and paste into the sheet we want to be restricted?

  • @rajhomealeti361
    @rajhomealeti361 3 года назад +2

    Some times getting error on line
    applications.Undo
    Please let me know solution
    Thanks

    • @sanketsancheti6320
      @sanketsancheti6320 2 года назад

      I am also getting the same error. Would you please help me, if in case you got the solution by now?

  • @sonnyjay1347
    @sonnyjay1347 6 месяцев назад +1

    Thank you brother

  • @starsumit2367
    @starsumit2367 3 года назад

    Bro I tried however it's not working I have multiple dropdowns can u please guide

  • @nirmalneeni
    @nirmalneeni 8 месяцев назад +1

    Thank you

  • @concepcionfamilysessions9624
    @concepcionfamilysessions9624 2 года назад

    tried the code but does not work. wondering what im doing wrong

  • @bhaktiloke547
    @bhaktiloke547 3 года назад +2

    I can't see the code in ur description box.. Pls help

    • @ExcelBasement
      @ExcelBasement  3 года назад

      Private Sub Worksheet_Change(ByVal Target As Range)
      Dim xValue As String
      Dim xCheck1 As String
      Dim xCheck2 As String
      If Target.Count > 1 Then
      Exit Sub
      End If
      Application.EnableEvents = False
      xValue = Target.Value
      On Error Resume Next
      xCheck1 = Target.Validation.InCellDropdown
      On Error GoTo 0
      Application.Undo
      On Error Resume Next
      xCheck2 = Target.Validation.InCellDropdown
      On Error GoTo 0
      If xCheck1 = xCheck2 Then
      Target = xValue
      Else
      MsgBox "No pasting allowed!"
      End If
      Application.EnableEvents = True
      End Sub

    • @zafarsayeed3107
      @zafarsayeed3107 Год назад

      @@ExcelBasement This code is not help for prevent the pasting in the sheet, able to paste from another workbook and other platform... I'm also add in last - Application.CutCopyMode = False command. but still not get the result. Please help me to resolve. Thanks

    • @manishaprasad9618
      @manishaprasad9618 3 месяца назад

      @@ExcelBasementwhere is the code

  • @jarisssiraj
    @jarisssiraj Год назад

    Dear Sir Its not Working - kindly help i believe the code is not working

  • @ranaahmmed238
    @ranaahmmed238 3 года назад

    Not working in protect sheets. Pls help

  • @AbhishekSharma-yf7lh
    @AbhishekSharma-yf7lh Год назад +1

    Working

  • @sanketjoshi410
    @sanketjoshi410 7 месяцев назад

    Please share the code

  • @SweetSharayu
    @SweetSharayu 3 года назад

    i m unable to view description somebody can help me with code?

    • @ExcelBasement
      @ExcelBasement  2 года назад

      Private Sub Worksheet_Change(ByVal Target As Range)
      Dim xValue As String
      Dim xCheck1 As String
      Dim xCheck2 As String
      If Target.Count > 1 Then
      Exit Sub
      End If
      Application.EnableEvents = False
      xValue = Target.Value
      On Error Resume Next
      xCheck1 = Target.Validation.InCellDropdown
      On Error GoTo 0
      Application.Undo
      On Error Resume Next
      xCheck2 = Target.Validation.InCellDropdown
      On Error GoTo 0
      If xCheck1 = xCheck2 Then
      Target = xValue
      Else
      MsgBox "No pasting allowed!"
      End If
      Application.EnableEvents = True
      End Sub

  • @rizwanhameed1656
    @rizwanhameed1656 4 года назад +3

    Raheem paste the code

    • @ExcelBasement
      @ExcelBasement  4 года назад +2

      Private Sub Worksheet_Change(ByVal Target As Range)
      Dim xValue As String
      Dim xCheck1 As String
      Dim xCheck2 As String
      If Target.Count > 1 Then
      Exit Sub
      End If
      Application.EnableEvents = False
      xValue = Target.Value
      On Error Resume Next
      xCheck1 = Target.Validation.InCellDropdown
      On Error GoTo 0
      Application.Undo
      On Error Resume Next
      xCheck2 = Target.Validation.InCellDropdown
      On Error GoTo 0
      If xCheck1 = xCheck2 Then
      Target = xValue
      Else
      MsgBox "No pasting allowed!"
      End If
      Application.EnableEvents = True
      End Sub

    • @caesarqaiser5908
      @caesarqaiser5908 3 года назад

      @@ExcelBasement its not working. When i paste this code in module and press run sub .. macro dialog box opens which only allow creating a new macro.. wht is the solution to ths? Why ths macro not showing in macros list?

  • @asimali5820
    @asimali5820 3 года назад

    Sir, please share this VBA code

    • @ExcelBasement
      @ExcelBasement  2 года назад +1

      Private Sub Worksheet_Change(ByVal Target As Range)
      Dim xValue As String
      Dim xCheck1 As String
      Dim xCheck2 As String
      If Target.Count > 1 Then
      Exit Sub
      End If
      Application.EnableEvents = False
      xValue = Target.Value
      On Error Resume Next
      xCheck1 = Target.Validation.InCellDropdown
      On Error GoTo 0
      Application.Undo
      On Error Resume Next
      xCheck2 = Target.Validation.InCellDropdown
      On Error GoTo 0
      If xCheck1 = xCheck2 Then
      Target = xValue
      Else
      MsgBox "No pasting allowed!"
      End If
      Application.EnableEvents = True
      End Sub

  • @deokarkaran1
    @deokarkaran1 3 года назад

    Hello,
    Please provide the macros used in the video