Delete From Non Active Sheet

Nov 22, 2011

I am not sure why this code won't delete, I can't believe excel requires the sheet to be active to delete from. It will only work if the .activate line is included.

How can you delete from another worksheet without first switching to it?

Code:

'Sheets("sheet1").Activate
Sheets("sheet1").Range(Cells(row, col), Cells(row + 7, col)).Delete shift:=xlUp

View 3 Replies


ADVERTISEMENT

Delete Rows That Contains Zero And Copy Active Sheet To New Sheet

Oct 2, 2009

I want DELETE the rows that contains 0 (zero or -) in column F (SALDO BRUTO), when I click the Button (Clear). And How I can copy from this sheet to a new sheet in this workbook, but the names of new sheet automatic rename to next date or 2, and next when I click the Button "Copy to New Sheet".

View 2 Replies View Related

Delete Shapes But Not Active X Controls Box On Same Sheet In VB

Mar 12, 2013

I have an active x control command button on the same sheet as some shapes (lines,circles) which are generated from some parameters. I want to be able to delete the current shapes so I can plot the next shape. Below is the delete shapes part of the code, not sure how to complete the code.

Currently, the box is getting deleted as well as the shapes

Code:

Private Sub CommandButton1_Click()
Dim line1_Beginx As Single, line1_beginy As Single, line1_endx As Single, line1_endy As Single
Dim line2_Beginx As Single, line2_beginy As Single, line2_endx As Single, line2_endy As Single

[Code]....

'Calculate positions of line vertices for plots

line1_Beginx = 1000
line1_beginy = 1000
line1_endx = 1000 + CD_2
line1_endy = 1000

[Code]....

View 2 Replies View Related

Delete Specific Type Of Chart From Active Sheet

Feb 20, 2009

i'm trying to delete a specific type of chart from the active sheet using this macro:

View 2 Replies View Related

Select/Delete Worksheet Text Boxes Using VBA On Active Sheet

Nov 10, 2009

I could use some assistance in creating a macro that will delete all and only text boxes on the active sheet. Some text boxes will be empty, but I still wish for them all to be deleted. Through searching the forums I see a similiar code, but it deletes all shapes on the active sheet:

View 8 Replies View Related

Macro With Reference To Active Chart On Active Sheet

May 14, 2014

I currently have the following macro running to set a chart's data values:

Sub C3Quarter12013()
'
' C3Quarter32013 Macro
'
'
ActiveSheet.ChartObjects("Chart 2").Activate
ActiveChart.PlotArea.Select
ActiveChart.SeriesCollection(1).Values = _

[Code] ......

When I copy the tab and change some of the data within the cells, I want the macro refer to the chart on the current tab and the values in the current tab - as currently it refers to only "Chart 2" and the values in the tab 'Figure 2 - WE OPH'.

I've tried changing the sheet name to ActiveSheet.name but that doesn't seem to work.

View 4 Replies View Related

Delete Active Workbook

Oct 10, 2004

if it is possible to delete the current workbook that is open?

I'm thinking of using an add-in to delete the workbook i'm viewing

View 9 Replies View Related

Delete Row Of Active Cell

Mar 26, 2008

I have a macro for deleting a row. I want iit to delete the row that I have selected, that is i if I mark cell B22 I want it to delete row 22. But it deletes the row under it, that is 23.

Sub Tabortrad()
Dim intRadnr As Integer
Dim intStartrad As Integer
Dim intSlutrad As Integer
intRadnr = ActiveCell.Row
intStartrad = ActiveSheet.Range("Första").Row + 1
intSlutrad = ActiveSheet.Range("Sista").Row - 2
If intRadnr < intStartrad Or intRadnr >= intSlutrad Then
MsgBox "Kan inte radera denna rad. Placera markören på en av bokföringsraderna mellan rad " & intStartrad & " och rad " & intSlutrad - 1 & "." & Chr(13) & "En ny rad kommer att infogas under den rad där markören står.", vbOKOnly, "Felaktig rad markerad".......................

View 2 Replies View Related

Delete Sheets In Active Workbook

Nov 27, 2008

I want to create a macro to check through all sheets in an active work book, if a sheet is empty, then delete it?

View 2 Replies View Related

Delete N Rows From Active Cell

Jun 12, 2009

Is there a quick way to delete "N" rows from the active cell regardless of the content of the cells in those rows? I import text files into excel then frequently have to go through them and delete rows of nonimportant data.

For example if cell A57 is currently selected can I run a macro that will delete the next 10 rows?

View 2 Replies View Related

Update Table On Another Sheet With Information On ACTIVE SHEET Based On Column Search?

May 14, 2014

What I have is a sheet that is copied periodically from some source sheet, and on this sheet is a table. This sheet is called "Onsite Checklist Template" and it's table is titled "Checklist". I also have another sheet called "Loggers and Initial Notes" which has a tabled titled "Record", and then finally a title sheet call "Proj Details".

To clear this intro up - The sheets, in their order, is: "Proj Details", "Loggers and Initial Notes", "Onsite Checklist Template". The tables: "Record" on "Loggers..." and "Checklist" on "Onsite..."

When the user wants to make a new site visit, he/she fills in the requested date and then selects a button on "Proj...". When this button is selected, it copies the table data on "Record" and puts it on "Checklist", then inserts a new worksheet tab, always in the 3rd position (the title is based on the site visit date in which the user entered), which is a copy of "Onsite...". Now we have another sheet with a table called "Checklist1", and upon another new site visit, there will be another worksheet with "Checklist2", and so on.

On the "Onsite..." worksheet, there is a button on it which also gets copied with the worksheet so that every new worksheet has this copied "Checklist ???" and this button. I'm looking for a macro that, when the button is selected, will bounce the active sheet's table "Checklist ???" off of "Record" and make changes as needed.

"Checklist ???" data range is B11:M20 (the header is on row 10); "Record" data range is B29:Q78 (the header is on row 28); Column headers are titled the same, just that "Record" has 4 extra columns, 3 in the middle and 1 on the end. "Checklist ???" columns 1-12 to "Record" columns 1-7, 10-12, 14-15. The search criteria is the 4th column in both tables ("Trk #").

I need the macro to do the following:If it finds a match, then update "Record" as needed with data from "Checklist ???", changing whatever cell is different in the row that contains the matching "Trk #", so long as the cell on "Checklist ???" is populated (i.e, if a cell on the target row of "Record" has a value, but it's blank on "Checklist ???", then "Record" wins; if it's blank on "Record", but populated on "Checklist ???", the Checklist wins. If both populated but different, then Checklist wins.If a "Trk #" exists on "Checklist ???" but is not on "Record" then add the line to "Record" (the 1st empty row, table size remains)I see no need for any "delete" at this time.

My concerns: The last column on record (column #16) is the filtering column for the worksheet copy event and needs to be left alone (it's formulated to produce a "Yes" or "No")I would like the ability to adjust table sizes if needed without modifying the macroThe table rows on "Checklist ???" will not be changed, deleted, or altered in any way by the macro.

View 2 Replies View Related

Macro Copy Of The Active Sheet And Then Rename The New Copied Sheet

Jul 30, 2009

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 9 Replies View Related

Copy Cell From Specific Sheet & Paste To Active Sheet

Mar 31, 2008

I would like a macro that will go to a fixed sheet, copy the format, go back to the previous sheet and paste the format. My problems arise going back to the previously activated sheet rather than just a fixed sheet.

View 2 Replies View Related

VBA - Delete Sheets In Active Workbook According To Combobox Value

May 8, 2014

That particular question has been solved, but now i need it to work with multiple values from combobox.

So for example,
if "Master" is selected in combobox3, it will delete sheets 7, 8
if "CSR" is selected in combobox3, it will delete sheets 1, 8
if "Original IND" is slected in combobox, it will delete sheets 1,7

The current code will work when "master" is selected, however i am getting compile errors when i select "CSR" or "Original IND"

WhenI select CSR, it does create a new wb for me (without sheets 1,8) correctly but i get a Run time error.

Run-time error '-2147417848 (80010108)': Automation error

The object invoked has disconnected from its clients.

When Original IND is selected, i get a compile error and it highlights 'Make the new workbook active newWBK.Activate

View 5 Replies View Related

Select Active Cells And Delete Entire Row

Oct 30, 2012

I have data that i import on a daily basis, the data can range from a couple of rows to thousands,

What I need to do using VBA is select the active cells, where cells in row ''G'' is blank then delete the entire row where that cell is.

View 3 Replies View Related

Copy Ranges From Active Sheet And Post To New Sheet

Aug 20, 2014

I have a workbook that I want to copy two separate ranges from and then post to two different sheets. Range one on the active sheet from A4:K(no of rows will vary) to sheet Savoury Year, and range two A64:K(no of rows will vary) to Site Services Year. When pasting I want to paste it to the next empty row down.

Copy of workbook attached : Weekly Accounts.xls‎

View 4 Replies View Related

Code Adds Data To Active Sheet Instead Of Specified Sheet?

Mar 12, 2014

What this code keeps adding the data to the active sheet instead of the specified "Users" sheet:

[Code]......

View 2 Replies View Related

Keep Hidden Sheet Made Visible As Active Sheet

Mar 2, 2007

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 7 Replies View Related

Copy Active Sheet And Another Sheet To A New Workbook

Jun 10, 2013

I am wanting to create a macro for excel that when run it it will copy the active worksheet and worksheet named "Timesheet" and copy them to a new Excel workbook named the same as the original file + "JobBrief".

View 3 Replies View Related

When A Sheet Is The Active Sheet Then Define A Range

Dec 14, 2008

When a sheet is the active sheet i use the following to define a range.

View 6 Replies View Related

How To Change Named Sheet To Active Sheet (VBA)

Jul 19, 2012

How do i change the below code to not reference a named sheet but the active sheet.

In case you need it i'm trying to sort columns A:CQ on row 2 smallest to largest from left to right.

Code:
Sub Sort_Left_Right()
' Sort_Left_Right Macro
Columns("A:CQ").Select
ActiveWorkbook.Worksheets("Sheet1").Sort.SortFields.Clear
ActiveWorkbook.Worksheets("Sheet1").Sort.SortFields.Add Key:=Range("A2:CQ2") _
, SortOn:=xlSortOnValues, Order:=xlAscending, DataOption:=xlSortNormal

[Code ..........

View 3 Replies View Related

Have Userform Populate Only Active Sheet Not By Sheet Name

Dec 4, 2012

I have a userform in my workbook with a button to access it on twenty different sheets in the workbook. Currently the userform will only populate the sheet titled "Blank1". How can I change it so it will populate the active sheet without naming it? So no matter what sheet I'm on when I hit the submit button the userform will populate only the sheet I selected the button on? See macro below.

Code:
Private Sub OKButton_Click()
Dim NextRow As Long
Sheets("Blank1").Activate

' Unprotect Sheet
ActiveSheet.Unprotect

[Code] ..........

View 2 Replies View Related

Copy/Paste From Active Sheet To Another Sheet

Sep 11, 2006

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 2 Replies View Related

Return To The Last Active Sheet

Sep 18, 2009

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 4 Replies View Related

Hide Sheet Whenever Not Active?

Dec 27, 2013

I'm looking for VBA code that will:

Hide a sheet whenever it is not the active sheet

View 3 Replies View Related

Check Only Active Sheet

Mar 22, 2007

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 9 Replies View Related

Jump To Last Active Sheet

May 29, 2008

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 9 Replies View Related

How To Run Macro From Active Sheet

Mar 18, 2009

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 9 Replies View Related

UDF #VALUE! Error On Non-Active Sheet

Jan 15, 2008

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 5 Replies View Related

Check If Sheet Is Active

Feb 10, 2008

I am in sheet1, Is there a code to check if the sheet 1 is active or not?

View 6 Replies View Related







Copyrights 2005-15 www.BigResource.com, All rights reserved