|
Output the Worksheet Name in a Cell in Excel - UDF
UDF to return the name of the worksheet in Excel on which this function is located. There are no arguments for this function. Simply input this function in any worksheet and this function will return the name of that worksheet.
This is a really easy to use UDF (user defined function) in Excel and it saves you a lot of time and work when you need to return the name of the worksheet in Excel in which you are working.
Where to install the macro: Module
UDF to Output the Worksheet Name in a Cell in Excel
Function SHEETNAME()
SHEETNAME = Range("A1").Parent.Name
End Function
How to Install the Macro
- Select and copy the text from within the grey box above.
- Open the Microsoft Excel file in which you would like the Macro to function.
- Press "Alt + F11" - This will open the Visual Basic Editor - Works for all Excel Versions.
Or For other ways to get there, Click Here.
For Excel Versions Prior to Excel 2007 Go to Tools > Macros > Visual Basic Editor
For Excel 2007 Go to Office Button > Excel Options > Popular > Click Show Developer tab in the Ribbon. Then go to the Developer tab on the ribbon menu and on the far left Click Visual Basic
- On the new window that opens up, go to the left side where the vertical pane is located. Locate your Excel file; it will be called VBAProject (YOUR FILE'S NAME HERE) and click this.
- If the Macro goes in a Module, Click Here, otherwise continue to Step 8.
- Go to the menu at the top of the window and click Insert > Module
- Another window should have opened within the Visual Basic Editor's window. Within this new window, paste the macro code. Make sure to paste the code underneath the last line of anything else that is in the window.
- Go to Step 8.
- If the Macro goes in the Workbook or ThisWorkbook, Click Here, otherwise continue to Step 8.
- Directly underneath your excel file called VBAProject(your file's name here), click the Microsoft Excel Objects folder icon to open that drop-down list.
- Then, at the bottom of the list that appears, double-click the ThisWorkbook text.
- A new window inside the Visual Basic Editor's window will appear. In this new window, paste the code for the macro. Make sure to paste this code underneath the last line of any other code which is already in the window.
- Go to Step 8.
- If the Macro goes in the Worksheet Code, Click Here, otherwise continue to Step 8.
- Directly underneath your excel file called VBAProject(your file's name here), click the Microsoft Excel Objects folder icon to open that drop-down list.
- Within the list that appears you will see every worksheet that is in that excel file. They will be listed as such: Sheet1(NAME OF SHEET HERE) and under that will be Sheet2(NAME OF SHEET HERE). Select the sheet in which you want the macro to run and double-click that sheet.
- A new window inside the Visual Basic Editor's window will appear. In this new window, paste the code for the macro. Make sure to paste this code underneath the last line of any other code which is already in the window.
- Repeat steps b and c for every sheet you want the macro to work in. Putting the macro in one sheet will not enable it for any other sheets in the workbook.
- Go to Step 8.
- Close the Microsoft Visual Basic Editor window and save the Excel file. When you close the Visual Basic Editor window, the regular Excel window will not close.
- You are now ready to run the macro.
Similar Helpful Excel Resources
Hello ppl!
I would like to create workbook with 2 worksheets. When I type in the cell an amount, that amount will be printed in a cell in second sheet. But when i write next amount in first sheet cell again that amount will be placed in cell bellow first one. Example: Sheet1 cell A1 > input = 11. Sheet2 cell A1 > output =11.
Sheet1 cell A1 > input = 9 Sheet2 cell A2 > output =9. Sheet1 cell A1 > input =6, Sheet2 cell A3 > output =6.
hello,
i have a long list of book titles i would like to append search prefixes and suffixes to which would be outputted in a new cell.
so for example:
Wind In The Willows would become:
Code:
http://www.google.com/search?q=Wind+In+The+Willows
or:
Code:
http://www.amazon.com/s/?url=search-alias%3Daps&field-keywords=Wind+In+The+Willows&Go=Go
so the formula is:
title, modified to change spaces into +'s, appended with prefix or suffix or both.
would something like this be possible?
any ideas appreciated!
thank you!
Hello everyone
I have the Formula:
VB:
=If(HOUR(R725)>=HOUR(B725);(NETWORKDAYS2(A725;Q725;65;datas!$K$2:datas!$K$500)-1)*24+HOUR(R725-B725);(NETWORKDAYS2(A725;Q725;65;datas!$K$2:datas!$K$500)-2)*24+HOUR(24+R725-B725))
If you like these VB formatting tags please consider sponsoring me in support of injured Royal Marines
The formula directly written into a cell works perfectly. The Problem is as soon as I add the part: ,datas!$K$2:datas!$K$500 in the code, Ill get a Runtime error. I tried it with using ASCII Character refference, but I get the error anyway.
wich I want the Macro to write into a Cell. What is working is this:
VB:
ActiveCell.Offset(0, 18) = "=IF(HOUR(RC[-1])>=HOUR(RC[-17]),(NETWORKDAYS2(RC[-18],RC[-2],65)-1)*24+HOUR(RC[-1]-RC[-17]),(NETWORKDAYS2(RC[-18],RC[-2],65)-2)*24+HOUR(24+RC[-1]-RC[-17]))"
If you like these VB formatting tags please consider sponsoring me in support of injured Royal Marines
Thanks in advance for any reply
I have arrays that I want to write from VBA to Excel. The Microsoft website gives advice and gives code similar to what's shown below (http://support.microsoft.com/default...b;en-us;306022).
My question relates to the following line:
DataArray(r, 11) = "=RC[+14]"
What this does is input a formula in column 11 from the same row but 14 columns to the right. * The cell contents in Excel have a formula in there, but what I need is a value. *
Any assistance would be appreciated.
Sub Update()
Dim DataArray(1 To 1000, 1 To 20) As Variant
Dim r As Integer
For r = 1 To 1000
DataArray(r, 1) = "ORD" & Format(r, "0000")
DataArray(r, 2) = Rnd() * 1000
DataArray(r, 3) = DataArray(r, 2) * 0.7
DataArray(r, 11) = "=RC[+14]"
Next
Sheets("Sheet1").Range("A1").Resize(1000, 20).Value = DataArray
End Sub
I have several worksheets in a workbook, I am trying to creat a sheet in the same workbook that summarizes the data in the other sheets.
I would like to be able to type the name of a sheet in column a of my summary sheet and then have cells in the same row linked to cells in that sheet.
Example:Have sheets: jobone, jobtwo, jobthree and summary.
I want c3, d3, e3 in summary to link to values in cells in jobone, or jobtwo, or jobthree depending on wich sheet name I enter in a3 of summary.
Is there a way to do this with out macros or code?
Okay Excel geniuses, let's see what you've got.
I am building a structure in Minecraft and need to do some math and have all of my ducks in a row before starting. Here's exactly what I have and will need:
In each inventory slot, you can hold up to 64 of a single item before another slot starts filling up. So if I have 70 stone blocks, I will have 1 full slot of stone blocks, plus 8 in another. If I have 255 stone blocks, I will have 3 full slots plus 63 in another. Got it?
I know MOD() will get the remainder, but I need to output this in a single cell with the number of full slots and the remainder together, so something formatted like "3 r63" or anything else easily readable is needed. There will be at least 123 different values, so an expression that I can copy and drag paste would be preferable.
suppose i have an array, like below:
Code:
Vehicle1 As String*2
MyArray(1)=mydata.Vehicle1
All I want to do is to sum each of the value in the array and output them in a cell of excel.
I do it like this
Code:
Sum = Sum.MyArray(1)
.Cells(lRow, 1) = Sum
but it is showing error. saying that object required.
What should I do?
Please help.
Hello all,
I have a macro (in access 2000 frontend talking to access 2000 backend) that is outputting a query to excel as follows:
MacroName Action
Cost-age OutputTo
Obect Type: Query
Object Name: Cost-Age
Output Format: MicrosoftExcel(*.xls)
Output File: C:\myfile.xls
Autostart: Yes
Template File:
Encoding:
Query:
SELECT [Cost-Age].[Age by Days], Format([Cost-Age].[Cost Sheet Number],"0.0") AS [Cost Sheet], Format([Cost-Age].Revenue,"$0.00") AS Revenue, Format([Cost-Age].Cost,"$0.00") AS Cost, [Cost-Age].[Invoice Printed], Format([Cost-Age].[Total File Revenue],"$0.00") AS [Total File Revenue], Format([Cost-Age].[Total File Cost],"$0.00") AS [Total File Cost]
FROM [Cost-Age]
ORDER BY [Cost-Age].[Age by Days] DESC, [Cost-Age].[Cost Sheet Number];
Query outputs to Excel, however all the number/currency fields are outputted as text and each cell has a green triangle in the left corner indicating this. If I select the fields in excel, right-click, and change the format of the fields to number or currency, the triangle still remains and I still cannot sum the cell contents.
What I would like is to output the numbers in access, as numbers in excel. Any help would be appreciated.
Hi all,
In my quest to lighten my suitcase I'm wondering if anyone knows which cellphones are capable of outputting excel files to a projector or TV? I know there are several phones that can run the excel software, but the screen size is so small it's virtually meaningless. Therefore I'm looking to output this image to my pico projector (or a TV) via composite signal. Anyone have any experience or suggestions?
TIA!
I have a spreadsheet with radio buttons of yes and no. I want to have a column give me the output of a calculation based on the radio buttons.
For example: if i pick "yes" button cell C1 will give me 3*7
if i pick "no" button cell C1 shows nothing
Can I use an if statement? Is there a way to do it without using Visual Basics? Cause I have no idea how to use Visual Basics
Also i created the radio button from the control toolbox not the form.
|
|