Here is a simple way to disable the Cut & Copy in the Popup menu
Sub Disable_Buttons()
Dim oC1 As CommandBar
Set oC1 = Application.CommandBars("CELL")
oC1.Controls("Cu&t").Enabled = False
oC1.Controls("&Copy").Enabled = False
End Sub
Other menu items can also be handled similarly
To disable the Insert & Delete in the Popup menu
oC1.Controls("&Insert...").Enabled = False
oC1.Controls("&Delete...").Enabled = False
Showing posts with label Copy matching data automatically through excel VBA. Show all posts
Showing posts with label Copy matching data automatically through excel VBA. Show all posts
Sunday, August 12, 2007
Monday, May 14, 2007
Dynamic Copy of Matching Excel Data
Copy specific data in cells from Master Sheet to Current Sheet
Most often we would have the entire data in Excel and would require data corresponding to the cell value taken from the master sheet and populated in the current one dynamically.
In the following example the master sheet is named as "DB" and contains all records with the primary key being the first column.
Function Snippet_For_Copy(sSearchString)
If Trim(sSearchString) = "" Then Exit Function
With Sheets("DB").Columns("A:A")
Set rFindCell = .Find(sSearchString, LookIn:=xlValues, LookAt:=xlWhole)
If Not rFindCell Is Nothing Then
Sheets("DB").Rows(rFindCell.Row).EntireRow.Copy _
Destination:=Range("A" & ActiveCell.Row)
End If
End With
End Function
If the user enters a data in the first column of the current sheet, the above function will check the data in the DB sheet and transfer entire row if a match is found
You can trigger the function using Worksheet_SelectionChange event
Private Sub Worksheet_SelectionChange(ByVal Target As Range)
If IsNumeric(Target) = False Then Exit Sub
If Trim(Target) = "" Then Exit Sub
Application.EnableEvents = False
Snippet_For_Copy Target.Value
Application.EnableEvents = True
End Sub

Most often we would have the entire data in Excel and would require data corresponding to the cell value taken from the master sheet and populated in the current one dynamically.
In the following example the master sheet is named as "DB" and contains all records with the primary key being the first column.
Function Snippet_For_Copy(sSearchString)
If Trim(sSearchString) = "" Then Exit Function
With Sheets("DB").Columns("A:A")
Set rFindCell = .Find(sSearchString, LookIn:=xlValues, LookAt:=xlWhole)
If Not rFindCell Is Nothing Then
Sheets("DB").Rows(rFindCell.Row).EntireRow.Copy _
Destination:=Range("A" & ActiveCell.Row)
End If
End With
End Function
If the user enters a data in the first column of the current sheet, the above function will check the data in the DB sheet and transfer entire row if a match is found
You can trigger the function using Worksheet_SelectionChange event
Private Sub Worksheet_SelectionChange(ByVal Target As Range)
If IsNumeric(Target) = False Then Exit Sub
If Trim(Target) = "" Then Exit Sub
Application.EnableEvents = False
Snippet_For_Copy Target.Value
Application.EnableEvents = True
End Sub
Subscribe to:
Posts (Atom)
Download Windows Live Toolbar and personalize your Web experience! Add custom buttons to get the information you care about most.