Hi there,
This code works great....I tried your next post, but it kinda of went for a
loop that I could not break. I do want this code to apply to all other
worksheets, but only when they are active. I will copy this code to all
sheets unless, you can think of another way. Thanks for your help.
"OssieMac" wrote:
> Hi Tim,
>
> Try the following
>
> Private Sub Worksheet_Change(ByVal Target As Range)
> Dim isect As Range
> Dim ws As Worksheet
>
> Set isect = Application.Intersect _
> (Target, Columns("G:H"))
> If Not isect Is Nothing Then
> Me.Application.ActiveWorkbook.RefreshAll
> For Each ws In Worksheets
> ws.Columns("G:H").AutoFit
> Next ws
>
> 'Not sure if you still want the following
> On Error Resume Next
> Target.Dependents.EntireColumn.AutoFit
> End If
>
> End Sub
>
> If you want to exclude any sheets then use the following code in the loop.
> You can expand the if statement if more than one sheet to excleude.
>
> For Each ws In Worksheets
> If ws.Name <> "MyShtToExclude" Then
> ws.Columns("G:H").AutoFit
> End If
> Next ws
>
>
> --
> Regards,
>
> OssieMac
>
>
> "Tim" wrote:
>
> > Hi there,
> > The code below works great ... BUT ... I need it to apply to only columns G
> > and H ...PLUS ... I would like to make this across the 25 worksheets I have.
> > Any ideas?
> > Thanks very much.
> > Private Sub Worksheet_Change(ByVal Target As Range)
> > Me.Application.ActiveWorkbook.RefreshAll
> > Target.EntireColumn.AutoFit
> >
> > On Error Resume Next
> > Target.Dependents.EntireColumn.AutoFit
> > End Sub
|