When A Sheet Is The Active Sheet Then Define A Range
When a sheet is the active sheet i use the following to define a range.
View Complete Thread with Replies
Sponsored Links:
Related Forum Messages:
Define Sheet Level Name Range Code
In general defining Sheet Level Name Ranges works fine with me, most of the times I use something like shown in the code below. However, I have discovered that apparently the successfull execution depends on the sheet-name format itself The code below works perfectly fine with worksheet names like "234", "cas422", etc but it fails to work with worksheet names like: "C12c", "eh34h4". It seems to me - but I am not sure of being able to generalize this - as if it works when the name contains [numbers][letters] or [letter][numbers], but it fails when it contains a mixture of both like [numbers][letters][numbers] or [letters][numbers][letters] .... in case of a failure of the code, I go into debug mode and simply rename the sheet, then everything's fine again. Am I the only one to experience such difficulties? (I run Excel 2003 with SP3 on Windows XP) Or would a different code prevent this kind of trouble? I think, I could write a workround, but before doing so I'd rather like to ask if I am doing something wrong here? ActiveWorkbook.Names.Add name:=wks.name & "!myTime", RefersToR1C1:="=" & wks.name & "!R1C1:R5C8"
View Replies!
View Related
Sort Range On Non Active Sheet
I'm trying to sort data on sheet1 and sheet2. I'm running all macros from sheet one and I need it to stay active all of the time. I'm using the following code to sort sheet2. When I sort the column on sheet2 with the code, I can not get back to sheet one without an error. Worksheets("Sheet2").Activate Columns("a:a").Select Selection.sort Key1:= Range("a1"), Order1:=xlDescending, Header:=xlGuess, _ OrderCustom:=1, MatchCase:=False, Orientation:=xlTopToBottom, _ DataOption1:=xlSortNormal I've tried Worksheets("Sheet1").Activate Columns("a:a").Select..............
View Replies!
View Related
Named Range That Refers To Active Sheet
is there a way to have the same named range cover a range of cells regardless of which sheet you are on? They seem to want to default to the page you are on. I want to make some VBA subroutines that will go over each sheet, and perform the same functions on each sheet. All sheets have the same format, but different data. I guess worst case scenario I can just break down and use multiple workbooks, but this seems a little less desirable. Should I be dividing this into seperate posts?
View Replies!
View Related
Copy Range Of Cells To Active Row In Second Sheet
Sheet 1 has data entered into it, it is then printed out as a jobsheet, saved and the data cleared. There are certain fields on this sheet that are eventually manually replicated onto sheet 2. The row in which they must go on sheet 2 will always be the 'activerow' on that sheet from a previous operation. It would make life so much easier and save lots of time if I could incorporate copying cells C10,C12,K8,K12,M2,C27 and C29 from sheet 1 to respective cells H,I,J,M,N,R,S of the active row on sheet 2 before I carry out the clear data process.
View Replies!
View Related
Macro Copy Of The Active Sheet And Then Rename The New Copied Sheet
I'm trying to create a copy of the active sheet and then rename the new copied sheet to what's in cell O4, which is a formula (see below) and then paste value cell O4 in B3 of the copied sheet. However, when I run this macro it doesn't seem to like the second line where I am renaming the sheet (run time error '1004'). "O4" =DATE(YEAR($B$3),MONTH($B$3)+1,DAY($B$3)) Sub NewMonth() ActiveSheet.Copy Before:=Sheets(Sheets.Count) ActiveSheet.Name = Range("O4").Value ActiveSheet.Range("O4").Copy ActiveSheet.Range("B3").PasteSpecial Paste:=xlPasteValues End Sub
View Replies!
View Related
Keep Hidden Sheet Made Visible As Active Sheet
I have a button on a sheet that runs a macro to unhide another sheet. That works, but I want the sheet made visible to remain forward. Instead, the button unhides the sheet and the sheet the button is on comes forward again. I am unable to figure how to keep the sheet made visible forward. Here is the macro 'as recorded'. Sub UnhideSheet1() Sheet2.Visible = True End Sub
View Replies!
View Related
Copy/Paste From Active Sheet To Another Sheet
I want to copy data from the current sheet, and past it in the "montly" sheet. 'i and j were defined above, with a Case statement Range(" Ai:Cj").Select Selection.Copy Sheets("monthly").Select ' I want the upper left cell of the pasted area to be A11 Range("A11").Select ActiveSheet.Paste I get an error saying that I should select one cell and then paste. But I thought that that is what I did...
View Replies!
View Related
Define Array On Different Sheet
I am having a problem defning arrays in VBA when they are on different sheets. When I do a step through the code it stops when I define an array which is not on the active sheet. Sub MMULT_Test() Dim wArray As Variant, xArray As Variant, yArray As Variant, zArray As Variant Dim Fn As Object Set Fn = Application.WorksheetFunction a = Sheets("Inputs"). Range("G33") b = Sheets("Inputs").Range("G34") c = b - 1
View Replies!
View Related
When Data File Close Sheet To Sheet Range To Range Copy
i have a main.xls file and two data file dat1.xls and dat2.xls mail named file have ar - br- cr- dr- er -fr sheets dat1 named file have ar-br-cr sheets dat2 named file have dr-er-fr sheets and all this files data source is colomn source a - fd row source 29-4000 i want to make two commandbutton to main file first for dat1 second for dat2 file and i need a code to use at this buttons to make when dat1 and dat2 close main file user when click first button copy dat1 file ar sheet colomn source a - fd row source 29-4000 cells to main file ar sheet colomn source a - fd row source 29-4000 cells copy dat1 file br sheet colomn source a - fd row source 29-4000 cells to main file br sheet colomn source a - fd row source 29-4000 cells copy dat1 file cr sheet colomn source a - fd row source 29-4000 cells to main file cr sheet colomn source a - fd row source 29-4000 cells
View Replies!
View Related
Check Only Active Sheet
I have this macro that looks in all sheets in column A, except the invoice sheet. How do I alter it to only check the active sheet? Dim ws As Worksheet For Each ws In ThisWorkbook.Sheets If ws.Name ("Invoice") Then On Error Resume Next With ws .Columns("A").SpecialCells(xlCellTypeBlanks).EntireRow.Hidden = True With .Columns("A").CurrentRegion .Offset(2, 0).Resize(.Rows.Count - 1, 3).SpecialCells(xlCellTypeVisible).Copy _ Sheets("Invoice").Cells(Rows.Count, "A").End(xlUp)(2) End With .Cells.Rows.Hidden = False End With Err.Clear End If Next ws
View Replies!
View Related
Jump To Last Active Sheet
Is there a way to create a macro to jump to the last active sheet? For example, the last sheet I was on was Sheet1 and now I'm on Sheet20 and I want to jump back to Sheet1 without scrolling through the tabs at the bottom of the screen.
View Replies!
View Related
Return To The Last Active Sheet
I have a spreadsheet that is nearly 100 worksheets. I am new to VBA and would like to put a button on each tab to return me to the last active sheet. I've tried other codes I've found on here but with no luck. I'm not sure if i'm posting them to the right area within VBA.
View Replies!
View Related
Sorting A Very Hidden Sheet That Is Not Active
I have tried to use absolute references (perhaps I didn't do it right) but it didn't work. Below is the code that does work but I need to first make the sheet visible then activate it. Sub Row_Sort(tmpsheet As String) ' Sort the first 4 columns of the tmpsheet sheet Dim tmprng As Range Dim OldActiveSheet As Worksheet ' Activate the desired workbook (in this case Linewkbk) Workbooks(LineWkbk.Name).Activate ' Save old active sheet Set OldActiveSheet = ActiveSheet.............
View Replies!
View Related
How To Run Macro From Active Sheet
I have written the below macro to copy data from a sheet called "Fixit Example 1" to a sheet called "Fixit Summary Example". It works fine, but I'd like to be able to run it from any "Fixit Example XX" worksheet. As written, the data is always copied from "Fixit Example 1" regardless of what worksheet I have open. I tried replacing Windows("Fixit Example 1.xls").Activate with Windows(Active.Worksheet).Activate but got an error "Run time error 424. Object required." Sub MoveData() ' ' MoveData Macro ' Macro recorded 18/03/2009
View Replies!
View Related
Vlookup Code For Non Active Sheet
I wrote this code today and it works - sometimes. Really it only seems to work when I have one of the sheets(zvur013) is in focus (ie, it was the last sheet to have been tabbed to). I dont understand what I'm missing, please help. Sub lookforitems() Dim items() Dim groupnums() Application. ScreenUpdating = False Set allitems = Workbooks("zvur013.dbf").Sheets("zvur013") Set allgnums = Workbooks("Groupnumbers.xls").Sheets("sheet1") Countgroups = Application.WorksheetFunction. CountA(allgnums.Columns(1)) countitems = Application.WorksheetFunction.CountA(allgnums.Rows(1)) ........................... allgnums.Cells(j + 1, i + 2).Value = x Debug.Print x Next j Next i End Sub
View Replies!
View Related
Find Active Sheet In A Workbook
I am creating a macro that will open another workbook and take all the contents off a page in it and paste the contents to itself. The problem is that sometimes those workbooks will only have one page and it will have the data I need, but sometimes there will be two or three pages in the workbook, but again, with only one sheet that has data on it. How can I have the macro find the one page with data on it?
View Replies!
View Related
Save Active Sheet To Another Workbook
Copy the active sheet that is open in a work book and save it to another file with the date in the name? For example Report_11-03-08.xls The only problem I see with this. How could I also make it append a letter to report if the file already exits Example saved as Report1_11-03-08.xls. Then just continue incrementing. Sub CopySave() Application.ScreenUpdating = False ActiveSheet.Copy Application.DisplayAlerts = False ActiveSheet.SaveAs Filename:=ThisWorkbook.Path & "/" & "Report_" & Format(Date, "mm_dd_yy") & ".xls" ActiveWorkbook.Close Application.DisplayAlerts = True Application.ScreenUpdating = True End Sub
View Replies!
View Related
Find Active Cell Value On Another Sheet
I am having problems getting a VBA search function to work... this is the code I am currently using with very little success: Sub FindApp() Selection.Copy Sheets("Applications").Select Cells.Find(What:="ADT32109", After:=ActiveCell, LookIn:=xlFormulas, _ LookAt:=xlPart, SearchOrder:=xlByRows, SearchDirection:=xlNext, _ MatchCase:=False).Activate End Sub What I am trying to achieve is to copy the contents of the active cell in the first sheet and find it within another sheet but I am unable to get the What:= section of the code to take the value of the copied cell.
View Replies!
View Related
Reference Chart By Name That Is Not On Active Sheet
I am trying to select cells, tables and charts by just knowing their name. Thus if possible I would like to only refer to a chart by its name i.e. not know what worksheet they are on. This seems to work for named ranges of cells/tables, but not charts (I can't get my named charts to appear in the "Define Name" dialog). I found this code that loops through charts on the activesheet and shows the names. However, I would much prefer not to have to specify the sheet or to loop through all the sheets trying to locate the one with the named chart. Public Sub GetEmbeddedCharts() Dim myChart As ChartObject Dim myCharts As ChartObjects Set myCharts = ActiveSheet.ChartObjects For Each myChart In myCharts Debug.Print myChart.Chart.Name Next End Sub
View Replies!
View Related
Disable Right Click When A Sheet Is Active
I need to display Excel Sheet in a Browser and I want to disable the Right Click and Menu of Excel(File, Edit). So in the method Workbook_Open i coded following Private Sub Workbook_Open() Application. CommandBars("Worksheet Menu Bar").Enabled = False Application.CommandBars(" Cell").Enabled = False Application.CommandBars("Sheet").Enabled = False Application.CommandBars("Ply").Enabled = False Application.CommandBars("Row").Enabled = False Application.CommandBars("Column").Enabled = False End Sub Private Sub Workbook_BeforeClose(Cancel As Boolean) Application.CommandBars("Worksheet Menu Bar").Enabled = True Application.CommandBars("Cell").Enabled = True Application.CommandBars("Sheet").Enabled = True Application.CommandBars("Ply").Enabled = True Application.CommandBars("Row").Enabled = True Application.CommandBars("Column").Enabled = True End Sub It works fine, but if I open Excel application before viewing this HTML page(which contains XLS) and then the option are also disabled in Stand alone Excel application. I want to disable option when for this Sheet which is opened.
View Replies!
View Related
UDF #VALUE! Error On Non-Active Sheet
I have data that is laid out as follows: Date, amount1, amount2 and a value in $ There are many rows, and there will be more than one row for each date. see attached worksheet for an example. I want to create a table that will provide me totals of the amounts and the value for each date. I have managed to do this, using subtotals, but this gets quite slow, and in any case I want to be able to reference each of the subtotals with another sheet, so I tried to use pivot tables. I managed to do the above by using three pivot tables Date/Amount1 then Date/Amount2 and finally Date/Value, and hiding the extra two date columns. However my next table of data contains 10,000 rows and over 20 columns, so I am wondering if the above can be done within one pivot table. I know very little about pivot tables, and when I try to drop a second data item in, it always puts it below the first rather than in a separate column, and I get a table looking like the one in the attached worksheet. Am I doing something very basic, wrong? Is it possible to get a single pivot table, to look like my first summary chart in the attached worksheet. If I can do it with three columns, then I should be able to extend it to my much larger table of data.
View Replies!
View Related
Referencing Active Cell's Value From Another Sheet
I'd like for users to click in a cell in col A in a sheet named "Period7", have the cell value placed in cell C11 in a sheet named "Per7Report," and change the focus or active sheet to sheet Per7Report. Can this be done simply by clicking in a cell, or must a command button be inserted into each cell (note - odd rows only) in col A in Period7. on the code to do this? Note that there is a formula in col A in sheet Period7
View Replies!
View Related
Insert 2 Lines Under Line 6 In The Active Sheet
I have to do a large amount of routine work with a large number of sheets. I have tried to record some macros to do the job. First of all I would like to insert 2 lines under line 6 in the active sheet. I then need to drag the formulas found in line 6 down over the two new lines. Thirdly i would like to change the text string "xxx" in the formulas found in line 7 to "yyy"
View Replies!
View Related
Rename Embedded Active Chart Sheet Name
For example, a cell on the screen is blank. When the page is printed, the "blank cell" has printed text. I checked "format cells" and it shows word wrap, merge cells, and left to right. I was told to "un-merge" the cells. I did that and I still have the problem. The color on all the cells is OK at a blue shade. When I look at print preview the cells are blank, but when the sheet is printed, the text shows. Also, it looks like there are 2-3 cells inside the main cell. I hope I have explained this properly, it is not easy to use the correct language to describe since I am not very good at using Excel.
View Replies!
View Related
Set TextBox ControlSource To Non Active Sheet
I need to use the Textbox ControlSource in some forms to read specific data from worksheets, different source sheet for each form. How do I tell the ControlSource to look at a specific cell in a specific sheet, rather than just the active sheet? I want to do this using the properties of the Textbox rather than VBA.
View Replies!
View Related
Macro To Update Links In Active Sheet Only
I have a workbook which has links to another excel workbook (source). This workbook has many sheets -all exact copy- with different names. I changed startup prompt (edit->links) to "dont display the alert and dont update automatic links". Then I recorded a macro for updating links (from source) and assigned this macro to a button. What I want to do is when I click this update button I want links to be updated only on the active sheet that Im on. My problem is, when I press this button, it updates all links including other sheets (basically whole workbook). My current macro is (I dont know coding but I tried changing ActiveWorkbook to ActiveSheet but it didnt work): Sub update() ActiveWorkbook.UpdateLink Name:= _ "C:Documents and SettingsAlperDesktopExcelsource.xls", Type _ :=xlExcelLinks End Sub
View Replies!
View Related
Advanced Filter Active Sheet Macro Code
the macro mentioned below has been assigned to a combo-box form. I have 2 different datasets in the same sheet, they have the same headers (but named differently, myhead and myhead1) and the same adv filter criteria range (named as "dcrit") is applicable to both datasets. So, if an item is selected from the combo-box, both the datasets should get filtered according to same criteria. how i can combine the 2 IF LOOPS mentioned in the code? Sub myfilt() Application. ScreenUpdating = False If ActiveSheet.FilterMode Then ActiveSheet.ShowAllData If Not (Range("indsignal")) Or Not (Range("countsignal")) Then Range(Range("myhead"), Range("myhead").Offset(1, 0).End(xlDown)).AdvancedFilter _ Action:=xlFilterInPlace, CriteriaRange:=Range("dcrit"), Unique:=False End If If Not (Range("indsignal")) Or Not (Range("countsignal")) Then Range(Range("myhead1"), Range("myhead1").Offset(1, 0).End(xlDown)).AdvancedFilter _ Action:=xlFilterInPlace, CriteriaRange:=Range("dcrit"), Unique:=False End If Application.CutCopyMode = False Application.ScreenUpdating = True End Sub
View Replies!
View Related
Indirect: Reflect The Data In The Active Sheet Or Give Me A #VALUE Error
I am running the formula =VALUE(RIGHT(CELL("filename"),15)) to read the tab name in a workbook with 90 sheets. When a new account is opened, the operator inserts a new sheet from a template (which contains the above formula), and labels the tab to the account number. The formula then 'reads' in the account number and performs look-ups based on it. The problem is that the sheets are only working when the sheet is active. They all seem to reflect the data in the active sheet or give me a #VALUE error. Where am I going wrong? How do I fix the problem?
View Replies!
View Related
Save Active Sheet As New Workbook, Formats & Values Only
I would like to link a macro to a button on the active sheet, that saves the active sheet In a New Workbook, with Format And Values Only. Preferably saved in the same location as the origonal workbook. This is my main goal. If possible I would like the new workbook to be named from a chosen cell (E19) on the active sheet with date added.
View Replies!
View Related
Creating New Sheet From Template Sheet & Filling In Summary Sheet - Userform
I have some experience with excel, but until now have not ventured into VBA and macros. I have a workbook which will have the following sheets: 1.Absence Summary sheet - Summarises data from each employee's individual sheet. 2. Template Sheet - A sheet formatted as an absence record sheet, but without data. 3. Individual employee Absence record sheets - Based on the Template sheet. I have read with interest the various posts and help files on User Forms & Macros, but have got a bit stuck. My Aim: ....
View Replies!
View Related
Create Macro To Chart Data With Location As Object In Active Sheet
I have been trying to create a macro in excel to chart a selection of data and to output the chart on the active sheet where the data was taken (as opposed to a named sheet). So basically, I have about 300 worksheets with data, and I would like to have a button on each page that automatically charts that data when clicked, and outputs the chart to the page where the macro was clicked. However, I have not been able to figure out a relative reference that will allow me to make the LocationasObject reference simply the ActiveSheet as opposed to a specifically named sheet. See my code below, which references an output to a worksheet called "Charts". Right now, all of my charts are outputting to the sheet called "Charts", as opposed to the active sheet. Sub ConsDiscChart() ActiveCell.Offset(29, 11).Range("A1").Select Selection.End(xlToLeft).Select Selection.End(xlToLeft).Select Selection.End(xlToLeft).Select Selection.End(xlToLeft).Select Selection.End(xlToLeft).Select Selection.End(xlToLeft).Select Selection.End(xlUp).Select Selection.End(xlUp).Select Selection.End(xlUp).Select Selection.End(xlUp).Select Selection.End(xlUp).Select Selection.End(xlUp).Select Selection.End(xlDown).Select ActiveCell.Offset(0, 1).Range("A1:B1").Select Range(Selection, Selection.End(xlDown)).Select ActiveCell.Offset(0, -1).Range("A1:C24").Select Charts.Add ActiveChart.ChartType = xlLineMarkers ActiveChart.Location Where:=xlLocationAsObject, Name:="Charts" With ActiveChart .HasTitle = False .Axes(xlCategory, xlPrimary).HasTitle = False .Axes(xlValue, xlPrimary).HasTitle = False End With End Sub
View Replies!
View Related
Create Copy Of Active Sheet & Convert Original To Values Only
I need to copy the Selected Sheet (Sheet name will be different each month) on a spreadsheet and paste the copy to the left of the selected Sheet. Then I need to copy and paste values the entire sheet of the sheet that the copy was made from (the one on the right). I am very new to macros, and I tried recording and manually editing the macro with no success. The number of sheets will be different always as I will be adding this to different workbooks and also because new sheets may be added to any workbook at any time. I attached my code that I came up with, as I am not familiar with code enought to "[code]" my code.
View Replies!
View Related
Copy Sheet & Create New Monthly Sheet From Present Sheet
I want to create a macro button that can create copy, insert, paste and rename the new sheet in next month's name, like if the active sheet's name is January, I want to copy the whole sheet of January, insert new sheet, paste the new sheet and rename the new sheet to next month like February? Also rename the new sheet (February) cell B3 the same as new sheet's name (February) So if month of February is near end, the macro button in February will create the same way as Jan did which means the next sheet will be named March and so on.
View Replies!
View Related
Copying A Certain Range In A Work Sheet To Another Existing Work Sheet Using VBA
I have a range of cells in a work sheet "sheet 1 " my objective is to filter this range according to certain criteria (i ve succeeded to do this ) yet what i want to do now is copy this data to another existing worksheet in a certain range . note :the existing worksheet to which i 'll copy the filtered data has some cells out of the range that i dont want to over write .. Simply :how to copy a selected range of cells in a work sheet to already existing work sheet in a specific range aswell .
View Replies!
View Related
Copy Data From One Sheet (Fixed Cells And Sheet) To Another Sheet
I want to be able to copy a name from one sheet (Available Players), paste it to a cell in another sheet (Round 1 through Round 20). The cell that will be copied is fixed but the place where it will be pasted will be different and may be on a different sheet. also i would like to change the color of the copied cell to "greyed" out or cut if it can not be greyed out. I have created a button and put in a macro that i created but have been having problems with it, generic 1004 errors that i can not figure out. i am attaching the document.
View Replies!
View Related
|