Re: Pivot Table Query
Hi Jamie,
Not sure if this is what you are looking for: Pivot Table sheet has Pivot Table on it with Pages for Answer Available and Source of email.
Bill
Bill
Re: Pivot Table Query
Hi Jamie,
Not sure if this is what you are looking for: Pivot Table sheet has Pivot Table on it with Pages for Answer Available and Source of email.
Bill
Bill
Re: File Protection
Hi jjob68,
If you put the following code into the ThisWorkbook module:
Private Sub Workbook_Open()
Dim ws As Worksheet
For Each ws In ThisWorkbook.Worksheets
If ws.Name <> "Main" Then ws.Visible = xlSheetVeryHidden
Next ws
End Sub
It will hide all of the sheets unless it is called 'Main'. Users will not be able to unhide the sheets by selecting Format|Sheets|Unhide, because it will not show any hidden sheets.
Place the following code in the Main sheet module:
Private Sub Worksheet_Change(ByVal Target As Range)
Dim ws As Worksheet
If Target.Address = "$IV$1" Then
If Target.Value = "Secret" Then
For Each ws In ThisWorkbook.Worksheets
ws.Visible = xlSheetVisible
Next ws
Application.EnableEvents = False
Target.Value = ""
Application.EnableEvents = True
Else
For Each ws In ThisWorkbook.Worksheets
If ws.Name <> "Main" Then ws.Visible = xlSheetVeryHidden
Next ws
End If
End If
Range("A1").Activate
End Sub
Display More
This will allow you to view and hide the sheets by typing in the password in cell IV1. You could use a command button, but this would just make the User curious and determined to access the data. You can hide the sheets at any time just by typing anything in cell IV1. Show the sheets by typing Secret in IV1.
Bill
Re: Pivot Table Query
Hi jamie,
What do you want to summarise it by:
Date, Policy No, Scheme No or something else?
Bill
Re: Validate Cell Range Via A Macro On The Save
Hi Bret,
You can do it with Worksheet_Change() event and Workbook_BeforeClose() event code.
The Worksheet change code will give a message if any of the data in the range is deleted. The Workbook before close code will not allow the workbook to be closed if the user has not filled in range B3:B11
Private Sub Worksheet_Change(ByVal Target As Range)
If Target.Cells.Count > 1 Then Exit Sub
If Not Intersect(Target, Range("B3:B11")) Is Nothing Then
If Target.Value = "" Then
MsgBox "Please enter appropriate data in cell" & Target.Address
Target.Activate
Cancel = True
Exit Sub
End If
End If
End Sub
Private Sub Workbook_BeforeClose(Cancel As Boolean)
If WorksheetFunction.CountA(Sheet1.Range("B3:B11")) < 9 Then
MsgBox "Please add appropriate data in cells B3:B11", vbCritical
Cancel = True
Exit Sub
End If
End Sub
Display More
The Workbook before close code should be placed in the This Workbook module and the Worksheet change code in the appropriate Worksheet module
Bill
Bill
Re: Count Of Valid Months Between Two Dates
Hi aravindvin,
Replace the 0 with "" in P1g5purt's formula if you don't want the zeros to show.
Bill
Re: Replace, Copy Then Replace Again
Hi Mazsola,
It works OK with me.
Bill
Re: Color Cells Based On Owner & Time (gannt Chart)g
Hi Kiwifinny,
You could also do this by using the Worksheet_Change() event.
Private Sub Worksheet_Change(ByVal Target As Range)
If Not Intersect(Target, Range("C4:N400")) Is Nothing Then
Dim iName As String
iName = Range("A" & Target.Row).Text
iindex = WorksheetFunction.VLookup(iName, Range("Names"), 3, False)
If Target.Value = "x" Or Target.Value = "X" Then
Target.Interior.ColorIndex = iindex
Else
Target.Interior.ColorIndex = xlNone
End If
End If
End Sub
Display More
This will automatically colour the cells as you enter the 'x' or 'X'. It will also remove the cell colour if you delete the 'x'.
Bill
Re: Color Cells Based On Owner & Time (gannt Chart)g
Hi Kiwifinny,
Sorry, I mucked up the colour codings from your colours in column A to the Names range. I have changed them now.
Bill
Re: Color Cells Based On Owner & Time (gannt Chart)g
Hi Kiwifinny,
If you could have blanks in column A, then you will have to adjust the code slightly. I have also changed the Range 'Names' by adding another column and adding the ColorIndex for each name into the new column, so that it automatically reads the color index when you select a new name in column A.
I have added the code to the button on the sheet.
Bill
Re: Color Cells Based On Owner & Time (gannt Chart)g
Hi Kiwifinny,
Sub AddColors()
Dim c As Range
Dim iCount As Integer
iCount = WorksheetFunction.CountA(Range("A4:A1200")) + 3
For i = 4 To iCount
For Each c In Range("C" & i, Range("IV" & i).End(xlToLeft))
If c.Value = "x" Then c.Interior.ColorIndex = Range("L" & i).Value
Next c
Next i
End Sub
Should do it for you.
Bill
EDIT: I have placed the ColorIndex numbers for each color in the rows in Column L, you can have them wherever you like, just change the code where it says "L" & i.
Re: Workbook Password Protect 2 Levels With 1 Pwrd
Hi Lionel,
I know you say you don't want to use the Save As, but if you use Save As and tick the Read Only Recommended checkbox, then you only have to put in one password, if you want access to it, if not just click the Read Only button.
Bill
Re: Find The Last Date Of The Week
Hi Reafidy,
This is totally different from the last post which asked for the number to be added to the spreadsheet if the latest week ending date was missing.
If you add a label to your form (Label1 in my code, probably different in yours), with the Visible property set to False, then add the following code to TextBox1 (may be different in yours) Before_Update event.
Private Sub TextBox1_BeforeUpdate(ByVal Cancel As MSForms.ReturnBoolean)
Dim dDate As Date
Dim dWeekEnd As Date
If TextBox1.Value <> "" Then
Label1.Visible = True
Else
Label1.Visible = False
Exit Sub
End If
Me.TextBox1.Value = Format(Me.TextBox1.Value, "dd/mm/yy")
dDate = Format(Me.TextBox1, shortdate)
dWeekEnd = 1 - Weekday(dDate) + 7 + dDate
Label1.Caption = dWeekEnd
End Sub
Display More
Hopefully this is what you are looking for.
Bill
Re: Auto Insert Invoice Number
Hi Revinrod,
The easiest way to do it would just be to put 2000 as your starting number in cell D3, then put a line of code in the macro that runs when you click the button to enter the Invoice into the database:
It depends on whether the command button to enter the invoice is from the Forms toolbar or the Control Toolbox on how you add this. It would be much easier if you could post the workbook.
First of all, copy the above code.
If the button is from the Forms toolbar, you will be able to right click on it, select Assign Macro and just before the End Sub line, paste the code.
If the button is from the Control Toolbox, select View|Toolbars|ControlToolbox from the Main Menu, click the Design Icon (the green triange), then double click the command button that enters the Invoice. This will take you to the code for the button. Just before the End Sub, paste in the code. Close the Code window and click the Design Icon again to turn it off. The code should now run.
Bill
Re: Select Single Cell After Paste Large Range
Hi Marc,
Can you post the rest of your code, maybe it could be adjusted so that you don't have to select any areas for copy or paste.
Bill
Re: Find The Last Date Of The Week
Hi Reafidy,
Thank you very much for your comments, they are most appreciated. Only too glad to help.
Bill
Re: Find The Last Date Of The Week
Hi Reafidy,
The following code will add the next week ending date after the last entry in column A, if the last entry is 7 days before today's date. I don't know if this is what you mean.
Private Sub UserForm_Initialize()
Dim dNum As Double
Dim dLatest As Double
dNum = Date
dLatest = Sheet1.Range("A65536").End(xlUp).Value
If dLatest <= dNum - 7 Then
Sheet1.Range("A65536").End(xlUp).Offset(1, 0).Value = dLatest + 7
End If
End Sub
Bill
Re: Omit Cells From Chart Data
Hi Triggman,
Can you post a sample of your workbook?
Bill
Re: Find The Last Date Of The Week
Hi Reafidy,
What is in a TextBox, the date or the End or Week date, or both? What kind of textbox is it, from the Control Toolbox, Forms Toolbar or Drawing Toolbar?
Bill