Auto refresh data

rakupareek

New Member
Joined
Dec 29, 2023
Messages
38
Office Version
  1. 2016
Platform
  1. Windows
VBA Code:
Private Sub Worksheet_Change(ByVal Target As Range)
Dim rng As Range
    Dim cell As Range
    Dim dataSheet As Worksheet
    Dim selectedValue As String

    Set rng = Me.Range("A4:A22")
    Set dataSheet = ThisWorkbook.Sheets("Data Input Sheet")
    If Not Intersect(Target, rng) Is Nothing Then
    Application.EnableEvents = False
      
For Each cell In Intersect(Target, rng)
            If cell.Value = "House Rent Allowance" Then
            Me.Range("P" & cell.Row).Value = dataSheet.Range("F14").Value
            ElseIf cell.Value = "Children Edu Allowance" Then
            Me.Range("P" & cell.Row).Value = dataSheet.Range("F18").Value
            ElseIf cell.Value = "Children Hostel Allowance" Then
            Me.Range("P" & cell.Row).Value = dataSheet.Range("F19").Value
            Else
            Me.Range("P" & cell.Row).ClearContents
            End If
        Next cell
        Application.EnableEvents = True
    End If
    Exit Sub
End Sub

Using this VBA but when I change some value in Data Input Sheet then data does not refresh.
Can possible to refresh data automatic when I change any value
 
Look for any code in the workbook that has Application.Enableevents = False in it.
 
Upvote 0

Excel Facts

Workdays for a market open Mon, Wed, Friday?
Yes! Use "0101011" for the weekend argument in NETWORKDAYS.INTL or WORKDAY.INTL. The 7 digits start on Monday. 1 means it is a weekend.
Then it may be that whatever code has that is not (always) resetting it back to True when it runs. If that happens, no other event code will run automatically.
 
Upvote 0

Forum statistics

Threads
1,223,885
Messages
6,175,184
Members
452,615
Latest member
bogeys2birdies

We've detected that you are using an adblocker.

We have a great community of people providing Excel help here, but the hosting costs are enormous. You can help keep this site running by allowing ads on MrExcel.com.
Allow Ads at MrExcel

Which adblocker are you using?

Disable AdBlock

Follow these easy steps to disable AdBlock

1)Click on the icon in the browser’s toolbar.
2)Click on the icon in the browser’s toolbar.
2)Click on the "Pause on this site" option.
Go back

Disable AdBlock Plus

Follow these easy steps to disable AdBlock Plus

1)Click on the icon in the browser’s toolbar.
2)Click on the toggle to disable it for "mrexcel.com".
Go back

Disable uBlock Origin

Follow these easy steps to disable uBlock Origin

1)Click on the icon in the browser’s toolbar.
2)Click on the "Power" button.
3)Click on the "Refresh" button.
Go back

Disable uBlock

Follow these easy steps to disable uBlock

1)Click on the icon in the browser’s toolbar.
2)Click on the "Power" button.
3)Click on the "Refresh" button.
Go back
Back
Top