Unknown problem with simple VBA code

N

norika

Dear all,

I am going to create a label form (A1:C12) for the junior, firstly I create
code in workbook open to set the primary setting of cells and vaildiation
list .

Secondary , I need to make the first ten character of the cell (label)
bigger in(col A) and copy it to next two columns (col B,C) by Private Sub
Worksheet_Change(ByVal Target As Range) module.

Here I got two problems, after the user choose value from the pull down
list, it copy to another two columns but not desired formatting.

I suppose the code would take effect after the cell change, but the first
cell (col A) would take effect AFTER I REOPEN the same file.

No error prompt in the whole processing, I don't know which code have
mistake here.

thanks.


workbook open coding:

Application.ScreenUpdating = False

Columns("a:c").ColumnWidth = 32.25

Rows("1:12").RowHeight = 76.25


Range("A1:c12").Select
With Selection.Validation
.Delete
.Add Type:=xlValidateList, AlertStyle:=xlValidAlertStop, Operator:=
_
xlBetween, Formula1:="=newrng"
.IgnoreBlank = True
.InCellDropdown = True
.InputTitle = ""
.ErrorTitle = ""
.InputMessage = ""
.ErrorMessage = ""
.IMEMode = xlIMEModeNoControl
.ShowInput = True
.ShowError = True
End With

With Selection.Font
.Name = "Arial"
.FontStyle = "standard"
.Size = 18

End With
With Selection
.HorizontalAlignment = xlCenter
.VerticalAlignment = xlCenter
.WrapText = True

End With

Range("A1").Select

End Sub

*****************************************************

Private Sub Worksheet_Change(ByVal Target As Range)

On Error GoTo xit
Application.EnableEvents = False

If Not Intersect(Target, Me.Range("A1:b12")) Is Nothing Then
If Not IsEmpty(Target) Then

With Target
.Copy
.Resize(1, 2).Offset(0, 1) = .Value
End With

With Target.Characters(Start:=1, Length:=11).Font
.Name = "Arial"
.FontStyle = "?D¡PC"
.Size = 28
End With

End If
End If

xit:
Application.EnableEvents = True
End Sub
 

Ask a Question

Want to reply to this thread or ask your own question?

You'll need to choose a username for the site, which only take a couple of moments. After that, you can post your question and our members will help you out.

Ask a Question

Top