Hey CephasOz, thanks again for your response!
Just tried your code but I'm still getting a Value error in the cells!
Dunno if other codes come accross it an that's why it doesn't show.
So, I'll explain!
I've got a workbook with three sheets, a,b,c
a book contains all the data I need
b has lists for datavalidation
c is the new I created for Worksheet_Change Event
Code in a sheet has more an it's
VBA Code:
Private Sub CommandButton1_Click()
Dim xAddress As String
xAddress = "1:1000"
If CommandButton1.Value Then
Application.ActiveSheet.Rows(xAddress).Hidden = True
CommandButton1.Caption = "Show Row"
Else
Application.ActiveSheet.Rows(xAddress).Hidden = False
CommandButton1.Caption = "Hide Row"
End If
End Sub
Private Sub HIDE_Click()
'Dim ws As Worksheet: Set ws = ActiveSheet
Dim rCell As Range
Dim dValue As Date
Application.ScreenUpdating = False
'dValue = DateSerial(Day(Now), Month(Now), Year(Now))
'.AutoFilterMode = False
For Each rCell In Range("H1:H" & Range("A" & Rows.Count).End(xlUp).Row)
If rCell.Value <> "" Then
If rCell.Value < DateSerial(Year(Now), Month(Now), Day(Now)) Then
rCell.EntireRow.Hidden = True
Else
rCell.EntireRow.Hidden = False
End If
End If
Next rCell
Application.ScreenUpdating = True
End Sub
Private Sub Worksheet_Change(ByVal Target As Range)
SetVar "LU_" & Me.Name, Env_UserName()
End Sub
I put your code down at the end. Everything has breaks.
In b sheet
Only your code
Code:
Private Sub Worksheet_Change(ByVal Target As Range)
SetVar "LU_" & Me.Name, Env_UserName()
End Sub
And in a normal module I insered
VBA Code:
' Set a variable's value.
Function SetVar(ByVal strName As String, ByVal strValue As Variant) As Boolean
Dim cTypeString As MsoDocProperties
'
SetVar = False
On Error GoTo Err_Exit
cTypeString = msoPropertyTypeString
On Error GoTo New_Var
ThisWorkbook.CustomDocumentProperties(strName).Value = strValue
SetVar = True
Housekeeping:
Exit Function
New_Var:
Err.Clear
On Error GoTo Err_Exit
ThisWorkbook.CustomDocumentProperties.Add Name:=strName, LinkToContent:=False, Type:=cTypeString, Value:=strValue
SetVar = True
Resume Housekeeping
Err_Exit:
Err.Clear
Resume Housekeeping
End Function
' Get a variable's value.
Function GetVar(ByVal strName As String) As String
GetVar = vbNullString
On Error GoTo Err_Exit
GetVar = ThisWorkbook.CustomDocumentProperties(strName).Value
Housekeeping:
Exit Function
Err_Exit:
Err.Clear
Resume Housekeeping
End Function
' Environment value of UserName.
Function Env_UserName() As String
Env_UserName = Environ("UserName")
End Function
Which you sugested.
In =GetVar("LU_"&MID(CELL("filename",$A$1),FIND("]",CELL("filename",$A$1))+1,255))
Filename is the name of the file and not the sheet right?
Where doe's $A$1 reffer to?
1,255 is the row range right can I make it bigger like for 1000?