Search TeachExcel.com
TeachExcel.com
TE
Teach Excel MS Office Tutorials Excel Consulting Services Excel Forum
Excel Video Tutorials Excel Tips Free Excel Macros Excel Help Resources Contact TeachExcel
Video Tutorials
  • Free Macros
  • Excel Help Directory
  • Excel 2007 Resources
  • Keyboard Shortcuts
  • Excel Forum
  • Contact/About

Macros
Excel Tutorials For Macros

Output the Worksheet Name in a Cell in Excel - UDF


Bookmark and Share

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


Bookmark and Share


How to Install the Macro
  1. Select and copy the text from within the grey box above.

  2. Open the Microsoft Excel file in which you would like the Macro to function.

  3. 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

  4. 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.

  5. If the Macro goes in a Module, Click Here, otherwise continue to Step 8.

    1. Go to the menu at the top of the window and click Insert > Module
    2. 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.
    3. Go to Step 8.

  6. If the Macro goes in the Workbook or ThisWorkbook, Click Here, otherwise continue to Step 8.

    1. 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.
    2. Then, at the bottom of the list that appears, double-click the ThisWorkbook text.
    3. 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.
    4. Go to Step 8.

  7. If the Macro goes in the Worksheet Code, Click Here, otherwise continue to Step 8.

    1. 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.
    2. 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.
    3. 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.
    4. 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.
    5. Go to Step 8.

  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.

  9. You are now ready to run the macro.



Similar Helpful Excel Resources

Input In Single Cell Output In Other Worksheet - Excel

View Content
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.

Can Excel Append Prefixes And Suffixes To Cell Data And Output In New Cell? - Excel

View Content
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!

How To Output A Excel Formula To A Cell With Vba - Excel

View Content
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

Output Cell Value (not Formula) From Vba To Excel - Excel

View Content
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

Excel 2001:cell Value In C3 Linked To A Cell On Another Worksheet, Specify Wich Worksheet By Typing The Worksheet Name In C1 - Excel

View Content
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?

[excel 2010] Need To Output The Value And Remainder To A Single Cell - Excel

View Content
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.

Macro To Sum All Element In Array And Output It In One Cell Of Excel. - Excel

View Content
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.

Excel Cell Format Problem When Output From Query - Excel

View Content
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.

Cell Phone That Can Output Excel Files (to A Pico Projector Or Tv)? - Excel

View Content
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!

How Do I Get An Option Button In Excel To Output A Number I Choose To A Specific Cell? - Excel

View Content
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.

Random Tutorials
Extract Text from Cells - Intermediate Example
(Intermediate)
Remove #N/A Error Result from Empty VLOOKUP() Formulas
(Intermediate)
AND(), OR(), and IF() Statements/Formulas
(Intermediate)
Absolute and Relative Cell References
   - & INDIRECT() Function Introduction

(Easy)
Link Cells Between Worksheets
(Easy)
How to record a Macro - And what One is
(Easy)
Submit Inquiry Here
  • Prices From $10
Name:*
E-mail:*
Request:*
The macro(s) on this page will be sent with the request.
Contact | Privacy Policy | Disclaimer
Copyright© 2012 TeachExcel.com