+ Reply to Thread
Results 1 to 7 of 7

Merge two Private Worksheets_Change in VBA

  1. #1
    Registered User
    Join Date
    09-23-2019
    Location
    Czech Republic
    MS-Off Ver
    Excel 2016
    Posts
    9

    Merge two Private Worksheets_Change in VBA

    I'd like to merge two Private Worksheets_Change in VBA. Is any solution of this problem?

    Thank you for answer

    David


    First code

    Private Sub Worksheet_Change(ByVal Target As Range)
    Dim i As Integer
    For i = 2 To 100
    If Cells(i, "D").Value <> "" And Cells(i, "B").Value = "" Then
    Cells(i, "B").Value = Date
    Cells(i, "B").NumberFormat = "dd.mm.yyyy"
    End If
    Next
    Range("B:B").EntireColumn.AutoFit

    End Sub



    Second code

    Private Sub Worksheet_Change(ByVal Target As Excel.Range)
    Dim xRow As Long
    xRow = 2
    ThisWorkbook.ActiveSheet.Unprotect Password:="123456"
    ThisWorkbook.ActiveSheet.Cells.Locked = False
    Do Until IsEmpty(Cells(xRow, 1))
    If Cells(xRow, 1) < Date Then
    Rows(xRow).Locked = True
    End If
    xRow = xRow + 1
    Loop
    ThisWorkbook.ActiveSheet.Protect Password:="123456"
    End Sub

  2. #2
    Forum Expert Olly's Avatar
    Join Date
    09-10-2013
    Location
    Darlington, UK
    MS-Off Ver
    Excel 2016, 2019, 365
    Posts
    6,284

    Re: Merge two Private Worksheets_Change in VBA

    Try:

    Please Login or Register  to view this content.
    let Source = #table({"Question","Thread", "User"},{{"Answered","Mark Solved", "Add Reputation"}}) in Source

    If I give you Power Query (Get & Transform Data) code, and you don't know what to do with it, then CLICK HERE

    Walking the tightrope between genius and eejit...

  3. #3
    Registered User
    Join Date
    09-23-2019
    Location
    Czech Republic
    MS-Off Ver
    Excel 2016
    Posts
    9

    Re: Merge two Private Worksheets_Change in VBA

    Unfortunately it does not work. Neither macro is running. But at the same time there is no error message in VBA.

  4. #4
    Forum Expert Olly's Avatar
    Join Date
    09-10-2013
    Location
    Darlington, UK
    MS-Off Ver
    Excel 2016, 2019, 365
    Posts
    6,284

    Re: Merge two Private Worksheets_Change in VBA

    Make sure events are enabled.

    In the VBE immediates window, enter:
    Please Login or Register  to view this content.
    Thinking about it, you will need to disable events, within the routine - so try this:

    Please Login or Register  to view this content.
    Last edited by Olly; 09-23-2019 at 05:30 AM.

  5. #5
    Registered User
    Join Date
    09-23-2019
    Location
    Czech Republic
    MS-Off Ver
    Excel 2016
    Posts
    9

    Re: Merge two Private Worksheets_Change in VBA

    I'm new to this forum. How do i attach it please?

  6. #6
    Forum Expert Olly's Avatar
    Join Date
    09-10-2013
    Location
    Darlington, UK
    MS-Off Ver
    Excel 2016, 2019, 365
    Posts
    6,284

    Re: Merge two Private Worksheets_Change in VBA

    1. See my post edit above
    2. To attach a workbook, click on GO ADVANCED and then scroll down to Manage Attachments to open the upload window.

  7. #7
    Registered User
    Join Date
    09-23-2019
    Location
    Czech Republic
    MS-Off Ver
    Excel 2016
    Posts
    9

    Re: Merge two Private Worksheets_Change in VBA

    I hope I have attached this correctly.

    I noticed that I have number one in the original formula, even though the date is in the second column, my mistake. (see code)


    code
    Do Until IsEmpty(Cells(xRow, 1))
    If Cells(xRow, 1) < Date Then
    Attached Files Attached Files
    Last edited by d.franc299; 09-23-2019 at 06:40 AM.

+ Reply to Thread

Thread Information

Users Browsing this Thread

There are currently 1 users browsing this thread. (0 members and 1 guests)

Similar Threads

  1. Merge 2 Private Subs into 1
    By singerbatfink in forum Excel Programming / VBA / Macros
    Replies: 6
    Last Post: 05-22-2018, 04:24 AM
  2. [SOLVED] Merge two Private Sub Worksheets - Troubleshoot
    By Quivolt in forum Excel Programming / VBA / Macros
    Replies: 5
    Last Post: 04-12-2018, 03:03 PM
  3. Private Sub Worksheet_Change Merge help required.
    By darrenkaye in forum Excel Programming / VBA / Macros
    Replies: 1
    Last Post: 03-29-2013, 01:47 PM
  4. [SOLVED] Multiple Private Sub Worksheet_Change Merge
    By darrenkaye in forum Excel Programming / VBA / Macros
    Replies: 4
    Last Post: 03-24-2013, 07:04 PM
  5. Merge two sets of "private sub" VBA codes in a single sheet
    By Nexans in forum Excel Programming / VBA / Macros
    Replies: 0
    Last Post: 11-20-2012, 08:18 AM
  6. [SOLVED] Merge two Private Sub Worksheet_Change code
    By nickmax1 in forum Excel Programming / VBA / Macros
    Replies: 7
    Last Post: 08-14-2012, 07:46 AM
  7. Replies: 4
    Last Post: 08-04-2006, 01:50 AM

Tags for this Thread

Bookmarks

Posting Permissions

  • You may not post new threads
  • You may not post replies
  • You may not post attachments
  • You may not edit your posts

Search Engine Friendly URLs by vBSEO 3.6.0 RC 1