Question: How do I hide a row from being displayed in Excel 2003/XP/2000/97?
Answer: Select the entire row that you wish to hide.



Dear Friends, We have started online publishing in 2002, from that day we are improving the database of Information and knowledge so that we can serve you best as we can. This website will contain information About Excel Spreadsheets and soon you will get other topics as you desire. We are providing information Free of cost not only this you can send us your Questions and we will revert in 48 - 72 Hours. You can mail us at: excelansguru@gmail.com
Question: In Excel 2003/XP/2000/97, I want to be able to use a combo box (on another sheet) to display data from Sheet1 and then be able to edit that data and save the changes back to Sheet1. How can I do this?
Answer: This can be done with macro code.
Let's take a look at an example.
In our spreadsheet, our data is on Sheet1.
On Sheet2, we have our combo box which is linked to the data on Sheet1. When the user selects a customer in the combo box, the address and phone number will be automatically populated. The population of this data is done by a macro called PopulateData (which is the macro assigned to the combo box).
A user can then update the data on this sheet. In our example, we've changed Betty's address from 454 11th to 78 Granite St.
Next, we click on the Save Changes button. This calls a macro called SaveChanges.
The macro will update the corresponding data on Sheet1 and display the message above when it has completed.
Now if we go to Sheet1, we can see that the address for Betty has been updated.
You can press Alt-F11 to view the VBA code. Select the module called Module1 in the left window.
The macro code looks like this:
The macro code for the Save Changes button:
Sub SaveChanges()
'Update data on Sheet1 based on changes made to data on Sheet2
Dim LProject As Integer
Dim LAddress As String
Dim LPhoneNbr As StringDim LRow As Long
Dim LFound As Boolean'Retrieve project number number
LProject = Range("H3").Value'Retrieve new address and phone number information
LAddress = Range("E5").Value
LPhoneNbr = Range("H8").Value'Move to Sheet1 to save the changes
Sheets("Sheet1").SelectLFound = False
LRow = 2
Do While LFound = False
'Found matching project, now update address and phone number information
If Range("A" & LRow).Value = LProject Then
LFound = True
Range("C" & LRow).Value = LAddress
Range("D" & LRow).Value = LPhoneNbr'Encountered a blank project number (assuming end of list on Sheet1)
ElseIf IsEmpty(Range("A" & LRow).Value) = True Then
MsgBox ("No match was found. Changes were not made.")
Exit Sub
End IfLRow = LRow + 1
Loop'Reposition back on Sheet2
Sheets("Sheet2").Select
Range("E5").SelectMsgBox ("Changes were successfully saved.")
End Sub
The macro code for the customer combo box:
Sub PopulateData()
Dim LProject As Integer
Dim LAddress As String
Dim LPhoneNbr As StringDim LRow As Long
Dim LFound As Boolean'Retrieve project number number
LProject = Range("H3").Value'Move to Sheet1
Sheets("Sheet1").SelectLFound = False
LRow = 2
Do While LFound = False
'Found matching project, now update address and phone number information on Sheet2
If Range("A" & LRow).Value = LProject Then
LFound = True
LAddress = Range("C" & LRow).Value
LPhoneNbr = Range("D" & LRow).ValueSheets("Sheet2").Select
Range("E5").Value = LAddress
Range("H8").Value = LPhoneNbr'Encountered a blank project number (assuming end of list on Sheet1)
ElseIf IsEmpty(Range("A" & LRow).Value) = True Then
MsgBox ("No match was found for combo box selection.")
Exit Sub
End IfLRow = LRow + 1
LoopEnd Sub
Question: In Excel 2003/XP/2000/97, is there a way to link a check box to another cell? For example, I've made a checkbox and whenever the checkbox is clicked, I would like the current date to automatically appear in another cell. Is this possible?
Also I would like the date to not change whenever the worksheet is opened. For example, if a cell has been set to July 16th and the worksheet is opened on July 17th, I still want the cell to read as July 16th.
Answer: Because you don't want the cell value changing whenever the spreadsheet "recalculates", we'll have to create a macro to determine when to update the cell value.
Let's take a look at an example.
In our spreadsheet, there are two columns - column A contains a checkbox and column B contains the "linked" cell.
We've created various checkboxes in column A using the Control Toolbox toolbar. To view the Control Toolbox toolbar, select Toolbars > Control Toolbox under the View menu.
When the checkbox in column A is "checked", the associated cell in column B will be updated with the current system date. When the checkbox is "unchecked", the associated cell value will be cleared.
This is accomplished with a macro called Process_Checkbox. You can view the macro by pressing Alt-F11.
The macro determines what row the checkbox resides in and then "sets the value" of the associated cell in column B.
The macro code looks like this:
Sub Process_CheckBox(pObject)
Dim LRow As Integer
Dim LRange As String
'Find row that checkbox resides in
LRow = pObject.TopLeftCell.Row
LRange = "B" & CStr(LRow)
'Change date in column B, if checkbox is checked
If pObject.Value = True Then
ActiveSheet.Range(LRange).Value = Date
'Clear date in column B, if checkbox is unchecked
Else
ActiveSheet.Range(LRange).Value = Null
End If
End Sub
Private Sub CheckBox1_Click()
Process_CheckBox CheckBox1
End Sub
Private Sub CheckBox2_Click()
Process_CheckBox CheckBox2
End Sub
Private Sub CheckBox3_Click()
Process_CheckBox CheckBox3
End Sub
Private Sub CheckBox4_Click()
Process_CheckBox CheckBox4
End Sub
Private Sub CheckBox5_Click()
Process_CheckBox CheckBox5
End Sub
Private Sub CheckBox6_Click()
Process_CheckBox CheckBox6
End Sub
Private Sub CheckBox7_Click()
Process_CheckBox CheckBox7
End Sub
Question: In Excel 2003/XP/2000/97, is there a way to link a check box to another cell? For example, I've made a checkbox and whenever the checkbox is clicked, I would like the current date to automatically appear in another cell. Is this possible?
Also I would like the date to not change whenever the worksheet is opened. For example, if a cell has been set to July 16th and the worksheet is opened on July 17th, I still want the cell to read as July 16th.
Answer: Because you don't want the cell value changing whenever the spreadsheet "recalculates", we'll have to create a macro to determine when to update the cell value.
Let's take a look at an example.
In our spreadsheet, there are two columns - column A contains a checkbox and column B contains the "linked" cell.
We've created various checkboxes in column A using the Forms toolbar. To view the Forms toolbar, select Toolbars > Forms under the View menu.
When the checkbox in column A is "checked", the associated cell in column B will be updated with the current system date. When the checkbox is "unchecked", the associated cell value will be cleared.
This is accomplished with a macro called Process_Checkbox. You can view the macro by pressing Alt-F11.
The macro determines what row the checkbox resides in and then "sets the value" of the associated cell in column B.
The macro code looks like this:
Sub Process_CheckBox()
Dim cBox As CheckBox
Dim LRow As Integer
Dim LRange As String
LName = Application.Caller
Set cBox = ActiveSheet.CheckBoxes(LName)
'Find row that checkbox resides in
LRow = cBox.TopLeftCell.Row
LRange = "B" & CStr(LRow)
'Change date in column B, if checkbox is checked
If cBox.Value > 0 Then
ActiveSheet.Range(LRange).Value = Date
'Clear date in column B, if checkbox is unchecked
Else
ActiveSheet.Range(LRange).Value = Null
End If
End Sub
Question: I have created a hyperlink from one worksheet to another within the same file. But when the linked worksheet is pulled up, I want to populate the designated field with some text. The text will change depending on the hyperlink selected, but all the links will connect to the same worksheet and the same field. The field I am wanting to populate controls numerous lookup functions.
HELP!! Can this be done?
Answer: Yes, this can be done by utilizing macros on two Excel workbook "events".
Let's take a look at an example.
In our spreadsheet, there are two sheets called Hyperlinks and Destination. The Hyperlinks sheet contains three hyperlinks in cell A3, A6, and A9. All three hyperlinks point to cell B2 in the Destination sheet
When a hyperlink is clicked, the Destination sheet is activated and cell B2 will display text showing which hyperlink was selected. In our example below, we've selected "Hyperlink #1" in cell A3.
You can view the macros by pressing Alt-F11 and double-clicking on the ThisWorkbook object in the left window.
There are three components to this solution:
The macro code looks like this:
Private Sub Workbook_SheetFollowHyperlink(ByVal Sh As Object, ByVal Target As Hyperlink)
'Update cell B2 in Destination sheet based on the origin of hyperlink
If Sh.Name = "Hyperlinks" Then
If GSourceCell = "A3" Then
Sheets("Destination").Range("B2").Value = "Hyperlinked from cell A3"
ElseIf GSourceCell = "A6" Then
Sheets("Destination").Range("B2").Value = "Hyperlinked from cell A6"
ElseIf GSourceCell = "A9" Then
Sheets("Destination").Range("B2").Value = "Hyperlinked from cell A9"
Else
Sheets("Destination").Range("B2").Value = ""
End If
End IfEnd Sub
Private Sub Workbook_SheetSelectionChange(ByVal Sh As Object, ByVal Target As Range)
If Sh.Name = "Hyperlinks" Then
'Capture last active cell on Hyperlinks worksheet and store in global variable
GSourceCell = Target.Address(False, False)
End IfEnd Sub
Answer: Below is a function that you can include in your spreadsheet to filter the final series of numbers in a hyperlink address in Excel.
Function FinalNumberSeries(pCell) As Long
Dim LChar As String
Dim LLength As Integer
Dim LStart As Integer
Dim LExit As BooleanLLength = Len(pCell)
LStart = LLength
LExit = False
'Search backwards through the string until a non-numeric
'character is found
Do Until LExit = True
LChar = Mid(pCell, LStart, 1)If IsNumeric(LChar) = False Then
LExit = True
ElseIf LStart = 1 Then
LExit = True
End If
LStart = LStart - 1
Loop
FinalNumberSeries = Mid(pCell, LStart + 2)End Function
Then you can reference this new function in your spreadsheet.
For example in cell B1, you could enter the following:
=FinalNumberSeries(A1)
Answer: Below are two functions that you can include in your spreadsheet to extract the complete hyperlink address for either a file of a web address.
Function HyperLinkText(pRange As Range) As String
Dim ST1 As String
Dim ST2 As String
Dim LPath As String
Dim ST1Local As String
If pRange.Hyperlinks.Count = 0 Then
Exit Function
End If
LPath = ThisWorkbook.FullName
ST1 = pRange.Hyperlinks(1).Address
ST2 = pRange.Hyperlinks(1).SubAddress
If Mid(ST1, 1, 15) = "..\..\..\..\..\" Then
ST1Local = ReturnPath(LPath, 5) & Mid(ST1, 15)
ElseIf Mid(ST1, 1, 12) = "..\..\..\..\" Then
ST1Local = ReturnPath(LPath, 4) & Mid(ST1, 12)
ElseIf Mid(ST1, 1, 9) = "..\..\..\" Then
ST1Local = ReturnPath(LPath, 3) & Mid(ST1, 9)
ElseIf Mid(ST1, 1, 6) = "..\..\" Then
ST1Local = ReturnPath(LPath, 2) & Mid(ST1, 6)
ElseIf Mid(ST1, 1, 3) = "..\" Then
ST1Local = ReturnPath(LPath, 1) & Mid(ST1, 3)
Else
ST1Local = ST1
End If
If ST2 <> "" Then
ST1Local = "[" & ST1Local & "]" & ST2
End If
HyperLinkText = ST1LocalEnd Function
Function ReturnPath(pAppPath As String, pCount As Integer) As String
Dim LPos As Integer
Dim LTotal As Integer
Dim LLength As IntegerLTotal = 0
LLength = Len(pAppPath)Do Until LTotal = pCount + 1
If Mid(pAppPath, LLength, 1) = "\" Then
LTotal = LTotal + 1
End If
LLength = LLength - 1
LoopReturnPath = Mid(pAppPath, 1, LLength)
End Function
Then you can reference these new functions in your spreadsheet.
For example in cell B1, you could enter the following:
=HyperLinkText(A1)
2009 Excel Guru All Rights Reserved. Blogger Templates created by Vikash Garg .
CSS by Vikash Garg