Auto Size Cells across two sheets

Padthelad

Board Regular
Joined
May 13, 2016
Messages
64
Office Version
  1. 2016
Platform
  1. Windows
I have two sheets that have data entered. Sheet 2 gets text from a particular cell on sheet 1.

When I enter data on sheet 1 the cell auto fits to show the text. This does not automatically happen on the corresponding cell on sheet 2.

Is there a way to have the cells on sheet 2 automatically auto fit to show the text entered on sheet 1?

All help is gratefully received.

Thanks,

Pad
 

Excel Facts

Highlight Duplicates
Home, Conditional Formatting, Highlight Cells, Duplicate records, OK to add pink formatting to any duplicates in selected range.
How is the text being entered into sheet 2?
Is this the result of a formula or a auto sheet event script?
 
Upvote 0
Thanks for your response. Text is entered as a formula. example: =+Quote!D17
 
Upvote 0
Try this:
This is a auto sheet event script
Your Workbook must be Macro enabled
To install this code:

Right-click on the sheet2 tab
Select View Code from the pop-up context menu
Paste the below code in the VBA edit window

Code:
Private Sub Worksheet_Activate()
ActiveSheet.UsedRange.Columns.AutoFit
End Sub
 
Upvote 0
Try this:
This is a auto sheet event script
Your Workbook must be Macro enabled
To install this code:

Right-click on the sheet2 tab
Select View Code from the pop-up context menu
Paste the below code in the VBA edit window

Code:
Private Sub Worksheet_Activate()
ActiveSheet.UsedRange.Columns.AutoFit
End Sub

Thank you for your response. That works really well!

I now have a new problem. I would like to protect the sheets from editing as they will be used company wide and I would like to prevent any unauthorized changes being made. The Autofit doesn't work when the sheets are protected. Is there a way to write VBA that would autofit with the sheets when they are protected?

Thanks

Pad
 
Upvote 0
I'm not sure how to do that. Maybe someone else here at Mr. Excel will have an answer for this.
 
Upvote 0
I'm not sure how to do that. Maybe someone else here at Mr. Excel will have an answer for this.

Hi,

I was able to overcome this by changing the setting for the 'protect worksheet'. I ticked the box for allowing 'row height' change.

Thank you for your help on this.

Pad
 
Upvote 0
That's great. I never deal with protected sheets.
Hi,

I was able to overcome this by changing the setting for the 'protect worksheet'. I ticked the box for allowing 'row height' change.

Thank you for your help on this.

Pad
 
Upvote 0

Forum statistics

Threads
1,215,394
Messages
6,124,683
Members
449,180
Latest member
kfhw720

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