Table Name Or Number For Current Worksheet
Apr 2, 2008
Does anyone know the VB syntax for obtaining a table name or number on an existing worksheet? I'm using Excel 2007 and have a worksheet that is one large table. I have a macro which copies the worksheet to a new sheet, converts the table to a range and then edits out the elements I don't require (my macro won't strip out information I don't require if it's still a table, which is why it's converted to a range). However, every time I copy the sheet, the table number increments by one.
For example: Unitlist is the original table name. When I copy the worksheet, the table on the copied sheet becomes Unitlist1. If I delete the sheet and copy it again, the table becomes Unitlist2 etc. etc. In order to get around this, I need to be able to reference the name of the table on the copied sheet and then use that reference to convert the table to a range. I can convert the table to a range using:
ActiveSheet.ListObjects("Unitlist1").Unlist
However, I need an automated way to obtain the table name. I've attached a copy of my macro for further reference.
Sub CopySheetDeleteData()
Dim c As Range
Dim i As Long
With Application
.Calculation = xlCalculationManual
. ScreenUpdating = False
Sheets("Units").Copy After:=Sheets("Units")
' rename the sheet
Sheets("Units (2)").Name = "ExportUnits"......................
View 2 Replies
ADVERTISEMENT
Oct 14, 2008
I have a worksheet with 30,000 rows. But sometimes even if I have fewer records in this worksheet(lets say 1000) worksheet shows the same 30,000 rows.And its annoying when you try to navigate using vertical scroll bar. Is there any option to re-adjust the worksheet to make it more user friendly based on number of rows in current sheet.
View 2 Replies
View Related
Jun 12, 2007
In cell A1, I have the month number (eg, 1, 2, 3,). The month number reflects current month and will automatically change with every month. For example, right now it’s 6, next month it will automatically change to 7. Each two columns in Range A10:X20 represents the data from January to December. I want to use a worksheet event to change the background of the current month two columns in the range to yellow color and the two columns in the range will be visible when I activate this sheet.
View 3 Replies
View Related
Jul 10, 2014
I have a spreadsheet for tracking jobs. Most everything is based off of week # rather than date. I am trying to get the stats page of the workbook to tally the total number of late jobs per week.The current week is taken care of because there is a function that automatically displays on time yes or no and I just set it to count the yeses or nos.The problem I am having is for past weeks.
I tried- =COUNTIF(Table2[On-time],"No"+(CountIF(Table2[Week # Hidden],"<Weeknum(Now())" but that doesn't work. I also tried isolating the < like this. =COUNTIF(Table2[On-time],"No"+(CountIF(Table2[Week # Hidden],"<"Weeknum(Now()) and that did not work either.
------ UPDATE
In response to using CountIFS I have also tried-
=COUNTIFS(Table2[On-time],"NO",Table2[Due Week '# Hidden],"<Weeknum(Now())") this just returns a zero value even when I have a late job listed three weeks ago.
View 10 Replies
View Related
Jan 18, 2012
I'm working on pivot tables using excel macro. Basically , I need to filter out the year submitted according to the current year . I did this to filter out my pivot :
For Each PivItem In _
PT.PivotFields("Year Submitted").PivotItems
PivItem.Visible = True
Next PivItem
For Each PivItem In _
PT.PivotFields("Year Submitted").PivotItems
Select Case PivItem.Name
Case "2012"
[code]....
But this can only filter out year 2012 . I need to use this workbook for the next couple of years and I dont want to keep modifying the codes .
View 6 Replies
View Related
Feb 6, 2012
Is there a formula to get the Name of the current Worksheet and place it in a Cell? I have a Macro that will create a list of all of the worsheets within a workbook, but it requires indexing through all worksheets. I have not found the command that returns the name of the active worksheet.
View 5 Replies
View Related
Nov 14, 2013
In my header I am trying to show the current page number and the total number of pages in the workbook. So if I have 10 pages in my workbook, page 5 would read "5 of 10".
I have this in my header "&[Page] of &[Pages]". All worksheets with 1 page read "1 of 1" and worksheets with 2 pages read "1 of 2" on the first page and "2 of 2" on the second page.
View 6 Replies
View Related
Jan 14, 2014
I have a workbook that we are using to track some training, the spreadsheet has the date of the course at the top and the trainee's name in column A
Additional sheets will be added each time a class is scheduled labeled with the date of the class and in the same format as the ones included titled: "1.13.14" & "1.20.14".
I need to add a table to the workbook that will collect ever new hire from column A and the Date of their class from cell "B1" in each sheet.
Copy of SLC-BD Peer Training 1.xlsx
View 4 Replies
View Related
May 16, 2011
I have to excel files, both have the same data. I created a pivot table macro on the first file. I want to be able to open the second file and use the shortcut to create the pivot table. the problem is that it refers back to the original workbook I created the macro on. How do I change the code to make it refer to the current workbook?
Code:
Sub Pivot()
'
' Pivot Macro
[Code]....
View 1 Replies
View Related
Mar 25, 2009
I basically need a macro to sort the sheet by V, U, T starting from row 3 and ending before the last vechicle. This is the problem though, the last vehicle ends everytime right before Car # in column A. So in other words in this example i would need it sorted by v u t, starting from 3 down to row 12. It ends at 12 because the next line includes car and a number.
Another sheet might have a longer list of vehicles and might end at row 100 before the next line has car number .
It always starts at 3, but the ending is dynamic where it should stop its selection before "car number ".
I would also like it to work on the current sheet im on, because i have up to 100 sheets like this and would not want it name dependant. Just want to click on a tab, and run a macro and have it sort from 3 down to the line before car in column A.............
View 3 Replies
View Related
Jan 22, 2013
What is the code to identify the current worksheet name? I want to store it in a variable so I can return to the worksheet later. I thought that the code was this:
myWorkSheetName = worksheet.name
:
:
Sheets(myWorkSheetName).Select
I receive a "Run-time error 424: Object required" message on the worksheet.name statement.
View 2 Replies
View Related
Feb 9, 2007
how to extract the current/active worksheet's file's name using VBA code. Let's say I have a an excel file with the name "Test.xls" Which function do I use to return Test (with or without the extension)?
View 4 Replies
View Related
Apr 5, 2009
So, I need to keep adding together all the numbers from cell row 0 upto and including the row number of the cell with the result. The column with the results is to the right of the column with numbers to add. So, if the numbers are positive, to the right of each should be an ever increasing number as a result. In the column with the numbers to add is a function which as a result gives either numbers or blank cells. It sounds simple but it is frustrating me. Why can't I use the function SUMIF with a ROW function inside the condition field? It always gives me 0 as the result. I use excel 2003.
I probably do't understand the SUMIF function but why isn't =SUMIF(A:A;"1>0") equivalent to =SUM(A:A). This too gives the result of 0. Why don't I get an error instead.
View 6 Replies
View Related
Dec 23, 2009
I have an application that when user insert a new row, it will place a dropdown box on first column of that row waiting user to make a selection to pupolate other attributes to the rest of columns of the row.
That runs fine if user follow the sequence precisely. That is, user create a row, make a selection, then create yet another new row, make a selection, and so on.
My trouble is that when user created a few rows consecutively without picking a selection from each dropdown first, but instead s/he first created a few rows (say on 21, 22, 23, 34, and 25) and then came back to make a selection from the dropdown box in row 21, the VB code would insist current working/active row number is 25, not 21. This becomes a big problem.
curRow = ActiveCell.Row
curRow = Selection.Row
both show curRow = 25, which are incorrect
Is there any mechanism that when user click on a dropdown, I will be able to get its correct position (row = 21, column = 1, for example) from the engaged dropdown box? In other programming languages "Me" is a reserved object that would give out individual's property, but I am not sure if that exists in Excel macro/VB.
I am new to Excel macro. I am looking for its answer for a few days and unfortunately I haven't found any clue yet.
View 7 Replies
View Related
Dec 22, 2009
there are 360 days in a year. is it possible for excel to show what is the current number of day?
eg. today is =350
View 9 Replies
View Related
Nov 6, 2009
I have a spreadsheet that I send emails from. Currently I use the .PrintOut command just before .send and it prints the email to the default printer. Instead of printing to the printer i want to print the email to pdf or any file for archive purposes. I would also like the file to be located on a network drive with a file name from a cell in the spreadsheet with todays date. Is this possible?
Currently the code looks like this:
VB:
With OutMail
.to = sh.Range("A1").Value [code]....
View 9 Replies
View Related
Dec 15, 2009
I need the cell address where the cursor is (in a non active worksheet).
View 5 Replies
View Related
Nov 6, 2009
I have a spreadsheet that I send emails from. Currently I use the .PrintOut command just before .send and it prints the email to the default printer. Instead of printing to the printer i want to print the email to pdf or any file for archive purposes. I would also like the file to be located on a network drive with a file name from a cell in the spreadsheet with todays date. Is this possible?
With OutMail
.to = sh.Range("A1").Value
.CC = ""
.BCC = ""
.Subject = sh.Range("H1").Value & " " & sarBody
.HTMLBody = strbody & "<br><br>" & "<H3><B>Specific Notes, If any...</B></H3>" & vbCrLf & varBody & Signature
.PrintOut
.send
End With
View 9 Replies
View Related
Jan 2, 2008
I put all my named ranges in a seperate worksheet in the workbook.
On a different sheet I have all my data with references to the named ranges. But what it gives me is the cell information from the sheet on which the named range is located and not on the worksheet where I actually need the calculations to be done.
How can I make the named range refer to the cells in the worksheet in which it sits?
Worksheet 1
---------------
1
2
3
4
Worksheet 2
--------------
I name the function Red apples
RedApples =CONCATENATE($A1&"Red Apples")
Worksheet 3
--------------
=RedApples
=RedApples
=RedApples
Question #1
How do I make the name reference in worksheet 2 refer to
the cells located in the worksheet in which i use it. In other words, when I use RedApples in Worksheet 3, it gives me what is sitting in A1 in worksheet 2 instead of in A1 on Worksheet 1.
Question #2
How do I make the name reference in Worksheet 3 keep stepping down along Column A in Worksheet 1?
Formula at issue in actuality is
=IF($S5>0.149,Morethan15,IF(AND($S5<0.15,$S5>0.999 ),Morethan10,IF(AND($S5<0.999,$S5>0.0499),Morethan 5,IF(AND($S5<0.05,$S5>0),Morethan0,IF($S5<0,Lessth an0)))))
the morethan15,10,5,0 and lessthan0 is defined in the last worksheet
View 6 Replies
View Related
Oct 27, 2011
I am trying to automate the creation of 3 pivot tables. At first I was having a problem with deselecting all items in the drop-down except one, then I found the code to fix it.
I replaced this code:
ActiveSheet.PivotTables("PivotTable15").PivotFields( _
"Beta")
.PivotItems("Escalated").Visible = False
.PivotItems("Hang Up").Visible = False
.PivotItems("New Hire Requests").Visible = False
.PivotItems("No Trouble Found").Visible = False
.PivotItems("Priority Exchange").Visible = False
[code].....
This fixed the problem, but there are still two other pivot tables that need to be created after this first one. I scrolled down through the code and deleted the other code blocks for the selection of the PivotItems and replaced it with the code above, but then when I ran it I got the "Compile Error: Duplicate Declaration in current scope".
I read more through the forum and realize that it's because VBA is dimensioning it twice, and I read that you're supposed to Dimension at the beginning of your program, but how do I implement this into my coding?
I can't dimension literally at the start of the code, there is some formatting that needs to take place first. (Basically I paste in a bunch of data into Sheet1 of my workbook, center it, space it out, then insert a pivot table into the pre-existing Sheet2 based on that data, filtered on the blank entries in Column N. Then I need to create ANOTHER pivot table based on that same data in Sheet1, but filtered on the blank entries in Column O. Then I center the words in the Pivot tables' headers in Sheet2, and finally I need to create one last pivot table on pre-existing Sheet3 based on the data on Sheet1, filtered for 2 specific entry types in Column N.)
View 2 Replies
View Related
Oct 26, 2006
Is it possible to get the current Page Item Selected for a pivot table
I've tried the following functions in VBA, but have had no success
CurrentPageName
CurrentPage
CurrentPageItem
ParentItems
View 9 Replies
View Related
Sep 26, 2011
I'm a novice at Excel trying to create some forms for work. My goal is to have a working workbook that holds all my values from multiple jobs that gets updated daily with additional worksheets that gets sent to me. I'd like to be able to hit a macro in my workbook that allows me to select a file that has been emailed to me and import their values into mine. For example:
While using my active workbook I want to select a file. Then take cells A1:A15 from selected file and paste to cells F1:F15 in my active workbook.
View 2 Replies
View Related
Nov 3, 2009
I have a worksheet that includes a cell that gives the current week of the month, in the form of "Week #". I've been using the formula below for several months and have had no issues until this month, and it's driving me crazy.
Given that cell D2 is the beginning of the week (usually Monday, but at the first of the month it may be a different day):
="Week " & ROUNDUP((DAY($D$2)+WEEKDAY(DATE(YEAR($D$2),MONTH($D$2),0)))/7,0)
I'm not sure where the logic is going wrong here; it's worked so well up until now. For the week beginning November 2, 2009, the formula above returns "Week 2" rather than "Week 1".
View 9 Replies
View Related
Jul 11, 2006
I have part of this routine working correctly. It will go and find the value I need and move to the next column using the Offset method, but now what am I doing wrong to try and get the code to select to the end of the current column?
Sub Find_First()
Dim FindString As String
Dim rng As Range
'FindString = InputBox("Enter a Search value")
FindString = Worksheets("Template").Range("A26").value
If Trim(FindString) <> "" Then
With Sheets("Service Level Score Paste Sheet").Range("A:A")
Set rng = .find(What:=FindString, _
After:=.Cells(.Cells.Count), _
LookIn:=xlValues, _
LookAt:=xlWhole, _
SearchOrder:=xlByRows, _
SearchDirection:=xlNext, _
MatchCase:=False)
rng.Select...........................
View 8 Replies
View Related
Nov 14, 2006
Need to find out exact date. if I insert 32.5 (32 years 5 months ) in particular cell. my output shld be 10 june 1974 or 10/06/1974. I want to find back date...
View 4 Replies
View Related
Sep 19, 2007
I have saved an Excel file based on today’s date using: ActiveWorkbook.SaveAs "S:MTL_DATA Stock Orders" & "Stock_Order_" & oname & Format(Date, "dd-mm-yy") & ".xls"
If I wish to save a second file in the same day I wish to save as the date with “_1” or date with “_2” for the third file etc. How do I alter the above code?
View 4 Replies
View Related
May 16, 2008
As I searched I see that JD "Julian Day" started from '4713/01/01' BC, counted 1 noon at noon. and suppose we are now in '2008/05/16', what is the algorithm of finding the days from '4713/01/01' BC through '2008/05/16'?
View 4 Replies
View Related
Nov 22, 2012
I know you can see it but If set to default when the mouse moves over an object it changes to that object's cursor. Access had a screen property that may have detected this change. Excel Examples On the worksheet the cursor is a cross If on a worksheet you have a shape with a macro the pointer changes to a hand On a shape without a macro the pointer is 6
HOW do you use vba excel to find its current number or send a message when it changes or peek message to notify when it changes
View 4 Replies
View Related
Jan 12, 2009
You could use:
If ActiveWorkbook.Sheets.Count < 17 Then
Application.CommandBars("Workbook tabs").ShowPopup
Else
Application.CommandBars("Workbook tabs").Controls("more Sheets...").Execute
End If
The code doesn't do anything on my excel workbook which currently has like 20 workbooks, and it grows daily by like 4 or 5 worksheets.
View 9 Replies
View Related
Mar 5, 2014
I am having trouble with my macro. I have attached excel sheet for reference.
Basically, I want a Macro that Looks up columns B & C of current sheet and matches it with table in the charges tab, and then returns hourly pay in column D.
I have created the macro but it's giving me Run time 1004 error.
Also, my formula is incorrect. Maybe that's why my macro isn't working?
2WayLookup_Macro.xlsm‎
View 4 Replies
View Related