ExcelBanter

ExcelBanter (https://www.excelbanter.com/)
-   Excel Programming (https://www.excelbanter.com/excel-programming/)
-   -   how to copy as I type and then lock? (https://www.excelbanter.com/excel-programming/414796-how-copy-i-type-then-lock.html)

beeblemonster

how to copy as I type and then lock?
 
Hi!

I'm writing a very large excel file and I need certain columns to be copied
into another tab as I type them, or press enter after each cell.
It's the first two columns of the first tab and I need them to be copied tp
the second tab and then locked in the second tab, but open to edit in the
first tab.

I tried using a macro but I really screwed it up.
Please help!!!

thanks!

Gary''s Student

how to copy as I type and then lock?
 
This is an example that you modify to suit your needs. There are two tabs s1
and s2. The users edits cols A & B in s1. After each change, the contents
of s1 are copied to s2 and s2 cols A & B are then protected:

Private Sub Worksheet_Change(ByVal Target As Range)
s = "A:B"
Set r = Range(s)
Set t = Target
Set s1 = Sheets("s1")
Set s2 = Sheets("s2")
If Intersect(t, r) Is Nothing Then Exit Sub
s2.Unprotect
s2.Range(s).Locked = False
s1.Range(s).Copy s2.Range(s)
s2.Range(s).Locked = True
s2.Protect
End Sub

--
Gary''s Student - gsnu200796


"beeblemonster" wrote:

Hi!

I'm writing a very large excel file and I need certain columns to be copied
into another tab as I type them, or press enter after each cell.
It's the first two columns of the first tab and I need them to be copied tp
the second tab and then locked in the second tab, but open to edit in the
first tab.

I tried using a macro but I really screwed it up.
Please help!!!

thanks!



All times are GMT +1. The time now is 07:10 AM.

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