I have many workbooks where I protect the sheets and I protect the project, and I don't need to unprotect it to run macros. I think that is n ot your problem.
Offset is commonly used to create a dynamic range, that is one that is not statically defined, but grows (and shrinks) as the data grows and shrinks.
This is achieved by embedding a function within offset that counts how many items are in the data. For instance...
Put a list of names in say M1:M10
Then, ensure cell A1 is empty and goto Tools>Options and on the Calculation
tab check the Iteration checkbox to stop the Circular Reference message.
Next, type this formula into cell B1...
Use this array formula as an example
=IF(ISERROR(SMALL(IF(Sheet1!$B$2:$B$20>2,ROW(Sheet1!$B$2:$B$20)),ROW(A1))),"",
INDEX(Sheet1!$A:$A,SMALL(IF(Sheet1!$B$2:$B$20>2,ROW(Sheet1!$B$2:$B$20)),ROW(A1))))
Assuming you added a new column B for the dates
Option Explicit
<br />
Private Sub Worksheet_Change(ByVal Target As Range)<br />
Const WS_RANGE As String = "B6:B1000" '<<<< change to suit</p>
<p> On Error GoTo...
Use this array formula for F4
=IF(ISERROR(SMALL(IF($A$4:$A$10=$F$2,ROW($A$4:$A$10)-ROW($A$4)+1),ROW(A1))),"",
INDEX(B$4:B$10,SMALL(IF($A$4:$A$10=$F$2,ROW($A$4:$A$10)-ROW($A$4)+1),ROW(A1))))
and copy down and across
Amit,
It is not better per se, but if you have a variable column, Cells can take a numeric column, which may be better when assigning via a variable, whereas Range must have a column letter(s).
Amit,
Try this
Sub CreateLoginDetails()
Dim i As Long
Dim lps As Long
lps = Range("C1").Value
For i = lps To 1 Step -1
With ActiveSheet
.Range("A" & i).Insert xlShiftDown
.Range("A" & i).Formula = "TAG POS=1 TYPE=A ATTR=TXT:Log<SP>Out"
.Range("A" & i).Insert xlShiftDown...
Try this
=INDEX(Sheet2!$C:$C,MATCH(1,(Sheet1!$A$1=Sheet2!$B$1:$B$20)*(Sheet1!$A2=Sheet2!$A$1:$A$20),0))
This is an array formula, so commit with Ctrl-Shift-Enter