ExcelBanter

ExcelBanter (https://www.excelbanter.com/)
-   Excel Discussion (Misc queries) (https://www.excelbanter.com/excel-discussion-misc-queries/)
-   -   Dorp-Down Formatting (https://www.excelbanter.com/excel-discussion-misc-queries/136675-re-dorp-down-formatting.html)

Gary''s Student

Dorp-Down Formatting
 
Here is a VBA example:

Suppose we have the data validation input in cell A1 and the actual list in
H1 thru H10 ( each item with its own unique format ). In worksheet code:

Private Sub Worksheet_Change(ByVal Target As Range)
If Intersect(Range("A1"), Target) Is Nothing Then
Exit Sub
End If
v = Target.Value
Application.EnableEvents = False
For i = 1 To 10
If v = Cells(i, "H").Value Then
Cells(i, "H").Copy
Target.PasteSpecial Paste:=xlPasteFormats
Application.EnableEvents = True
Exit Sub
End If
Next
Application.EnableEvents = True
End Sub

This routine activates once A1 is filled and then looks down the list to
find the match. Once found, the routine copies the format of the matched
cell back to A1

REMEMBER: worksheet code
--
Gary''s Student
gsnu200712



All times are GMT +1. The time now is 04:51 AM.

Powered by vBulletin® Copyright ©2000 - 2024, Jelsoft Enterprises Ltd.
ExcelBanter.com