Macro To Continue If There Is No Data To Select In Workbook
Aug 21, 2013
I have a macro that pulls in data from many workbooks. If there is no data in one of the workbooks the macro will not continue. Is there a loop or some other coding I need. The code for one of the worksheets is: (I am new to excel and know there must be parts that can be deleted in the below
Workbooks.Open Filename:= _
"J:SPORTSFORCESPORTSFORCE BUSINESS PLANSReporting spreadsheetCricket.xlsx"
Sheets("Numbers Report ").Select
ActiveSheet.Outline.ShowLevels RowLevels:=2
Range("A6").Select
Range(Selection, Selection.End(xlDown)).Select
Selection.Rows.Ungroup
[code]....
View 3 Replies
ADVERTISEMENT
May 5, 2014
I got a workbook with a database in sheet1. I filter that database and copy - paste values the results to a new sheet. Next, I save that new sheet to somewhere on my drive. The thing is that I want to go back to my original database, and continue filtering. But that workbook is no longer the "active workbook". This is how it works:
sub DifferentClients()
For Each FieldWorkBy In Array("Client1, Client2,...")
MyDatabase.AutoFilter Field:=CountryCode, Criteria1:=Array( _
[Code]....
View 3 Replies
View Related
Mar 26, 2012
Copy data from workbook, open existing workbook, select range and paste. But my copied data is lost.
Sub Select_Copy_Paste()
'
'
Windows("ElektroFunctiesDatabase.xlsm").Activate
Sheets("PowerSupply's").Select
Range("A2:I6").Select
Selection.Copy
[Code] .........
' Here i need to do something to paste data into r.address?
View 4 Replies
View Related
Aug 13, 2009
Basically in B3 I have number 1. I want a macro to go to the next empty cell down and continue the series, i.e. 2. Then if it is ran again it will go to the next cell down and put in 3. This is what I want it to do only I don't want it to reference ranges. I added the offset line in but still need to know how to autofill to the nex line down..
View 2 Replies
View Related
Nov 9, 2009
The last few days I have had great support in answering my questions. I would like to tweak the code one more step.. The RFQ LIST workbook grabs data from Inventory workbook after select the workbook.
This code in RFQ LIST allows to select the workbook, I would also like to select the workbook.sheet as found out they want to tab the data and keep long term history.
View 7 Replies
View Related
Apr 18, 2013
I want to a macro to start of with a Find method Eg Account..something like this
Cells.Find(What:="Account").Activate
Account could be in any row or may not be in the document.
My problem is when it is not in the workbook my macro will come up error. how to recode my macro to fix this.
Dim Finder as string
Set Finder = Cells.Find(What:="Account",...............
'Problem here
'
If Finder is not found then skip till next part of macro.
If it is then just select the Cell and I can work of that.
Also Can I do a Find formula to Find Either 'Account' Or 'Debt' Or Asset'?? Just want to know save me copy and pasting it down to change a name.
View 1 Replies
View Related
Nov 20, 2007
I have been able to put together a pretty hefty MACRO. I found out that some of the files I am importing may result in no data due to the manipulations I am doing. This causes a problem when I try to subtotal the data on each sheet. Is there a way to have the MACRO delete a sheet if cell a2 is blank and then continuw with the rest of the MACRO?
View 9 Replies
View Related
Mar 13, 2007
If cells A1:A3 contain text that needs to be combined in B1 but amount of data sent to B1 is of greater size than B1 can display because of surrounding cells is there a way to allow data not viewable to overflow into another cell?
View 5 Replies
View Related
Feb 21, 2014
I have 2 workbooks. The workbooks have 36 tabs for each department. Workbook 1 are current charges for the departments and workbook 2 is the revenue for each department. I would like to take the top 2 rows from workbook 2 and add them to workbook 1 at the bottom of each tab. I was able to get it to work to a specific row but the workbook 1 has variable rows for each tab.
View 3 Replies
View Related
Aug 9, 2006
I am having a problem with a custom funciton I am trying to create. It will exit after it is finished with the IF Then Else statement. I need it to continue onto the Do loop at the bottom that does all the work.
Function UPCECheck( num As String) As Long
Dim CheckNum As Long
Dim TempCheck As Long
Dim X As Long
Dim Holdtxt As Variant
UPCECheck = 0
CheckNum = 0
Debug.Print Len(num)
If Len(num) = 12 Then
Holdtxt = num
ElseIf Len(num) < 12 Then
Holdtxt = "000000000000" & num
Holdtxt = Val(Mid(Holdtxt, Len(holdtext) - 12, 12))
End If...................
View 6 Replies
View Related
Feb 4, 2014
I am looking for some code that would copy lines of data if the following to criteria are meet into anouther workbook caller YTD at the bottom of the data to provide a YTD summary.
If column h if marked "y" and todays date ( currently have a =Now() ) is 7 days or more thaen copy and paste to new workbook removing it from the current sheet.
View 2 Replies
View Related
Jan 27, 2013
I have data validation on all the pages in my workbook. How do I edit all the data validation at once.
View 4 Replies
View Related
Feb 8, 2014
* I have a workbook, with different sheets (with sheet name as Home, RawData, Data1, Data2, Data3, ...), these sheets are not fixed
* FYI... sheet (home) has a VBA code which on running creates a new sheet and pull data from some other source (So the sheet number is not fixed in the workbook, but the newly added sheet is named in a specific format as Data1, Data2, Data3, ...)
* So we can say, that the sheet number and name are not fixed (It keeps on changing)
* All these sheets have data in the same format starting from range A2:J2, except sheet(home)
Two things i am trying to do:-
- Select sheets from the workbook (to be consolidated)
- Consolidate selected sheets in a new sheet
Here is the sample file Select sheet then consolidate.xlsm
View 6 Replies
View Related
Oct 21, 2013
i have a macro that opens 10 other workbooks and copies cells onto a "master" workbook. Until recently, everything worked fine. Suddendly, while it opens the 9 books and copies as it is expected, but when it opens the 10th wb, the macro breaks at a very simple copy/paste.
The weirdest thing is that after it breaks, I cannot select any cells neither in the opened wb nor in the master wb. This continues even after I press the "reset" button in the vba. So, I am only able to select objects (text boxes etc) in my wb and not any cells.
Also, the "arrow" icon on the design toolbar is not active. And I've tried pressing and de-pressing the F8 key, but I still cannot select any cells.
I have option explicit in the beginning of my macro. And i'm using excel 2003.
View 2 Replies
View Related
Aug 7, 2013
I need a vb code which would open different workbook automatically, autofilter the first row and select data and copy and paste in the other workbook.
View 1 Replies
View Related
Feb 23, 2014
I have data in 2 different workbooks, and I need to transfer all data in 'Jx_ex1' to sheet1 in the 'template' workbook, and all data in 'Gr_ex1' to sheet2 in 'template' workbook. All data should be transferred to the same cell numbers, from A1 to Y5000. I actually have loads of workbooks to transfer to the template but if I have an example with the two then im sure I can work out how to modify it. All files will be in the same folder.
View 8 Replies
View Related
May 1, 2012
I am creating a spreadsheet to provide to a group of about 40 people. The spreadsheet allows each member to track the referrals they receive and give. I need to plan on creating updates for the spreadsheet and want to make it so they can easily transfer their data to the most current version in the future. Here is a breakdown of the workbook:
Worksheets:
Members
Lists
Referrals Given
Referrals Received
Totals
Formulas
I need to copy the data that they have input from the following worksheets:
Referrals Given
Referrals Received
Here is a breakdown of the "Referrals Received" worksheet:
A1:V4 - Data that will not change and includes many named cells
A5:Nxxx - Dynamic Named Range where they input their data
O5:Vxxx - Contains formulas
I need to be able to copy
A5:Vxxxxx
from the old workbook to the new
Some side items to note:
There is VBA in the worksheet of
Private Sub Worksheet_Change(ByVal Target As Range)
and included in the code is an Unprotect & Protect code to always keep the sheet protected
I figure whatever works for this sheet will work for all the sheets.
View 1 Replies
View Related
Sep 28, 2012
I have two workbooks open. I need to "Save As" and close workbook 2 with a file name from a cell in Workbook 1. The macro is running from workbook 1.
I'm guessing a change in the last line. I don't know what Dim means either.
Dim FName As String
Dim FPath As String
FPath = "G:"
FName = Sheets("sheet 1").Range("A1").Text
ThisWorkbook.SaveAs Filename:=FPath & "" & FName
View 1 Replies
View Related
Aug 20, 2009
I am pretty much a novice at this whole excel / vba stuff, but I have been trying! unfortunately I have now got well and truely stumped! I require the macro to perform a loop and once saved the first row of data, select the next row of data (in exactly the same way) until it reaches the last row. The macro I have created does the first part fine, but I have reached the end of my knowledge base!
Below is the macro I have created:
Sub TEST_1()
'
' TEST_1 Macro
' Macro recorded 20/08/2009 by ..........'
'
Sheets("Input").Select
Range("A1:CI1").Select
Selection.Copy
Sheets("Results").Select
Range("G3").Select
ActiveWindow.LargeScroll ToRight:=7
Range("G3:CO3").Select..............
View 9 Replies
View Related
May 12, 2014
Macro below - it now works and selects all the data in spreadsheet and converts to Proper Case
However I also need a macro to select all except the last column of data and convert all except the last column to Proper Case
It is for Post / Zip code info. so wish to keep it in Upper Case.
What I have already is:
Code:
Sub Propercase()
Dim LastRow As Long, LastColumn As Long
LastRow = Cells.Find(What:="*", After:=Range("A1"), SearchOrder:=xlByRows, SearchDirection:=xlPrevious).Row
LastColumn = Cells.Find(What:="*", After:=Range("A1"), SearchOrder:=xlByColumns, SearchDirection:=xlPrevious).Column
Dim r As Range, c As Range
Set r = Range("A1").Resize(LastRow, LastColumn)
[Code] .....
I was hoping I could easily amend the above to select all except last column.
View 3 Replies
View Related
Apr 8, 2007
I have a Data Validation list in cell A1 of a worksheet called LIST. I would like to modify the macro that I have recorded, the macro uses data from various worksheets. I would like to sort out some code so that at certain points in the macro it will select the worksheet that is shown in cell A1 of the LIST sheet and then carry out the code already recorded. THis will allow me to quickly change a sheet name that is refererred to in the macro numerous times without actually manually editing the sheet name in the macro code.
View 7 Replies
View Related
Nov 30, 2008
I have a macro that automatically takes data from one sheet, copies it and pastes it on another sheet, but I want it to select the empty column that is to the right of the last column to contain data (so basically the next empty column). What code would I enter into editting my macro to be able to do this please?
Also, one thing I've tried to do with my macro is that when I select the data, it's suppose to select from the first name to the last. When doing the actions for the macro, I use "Ctrl + Shift + Down Arrow Key" to make the selection select the bottom of the list. However, when running the macro, if the list is longer (or shorter), the macro selects that number of cells instead of the action of just going to the bottom of the list. For example, if during the actions of the macro, I recorded using the Ctrl + Shift + Down Arrow Key that 50 cells were selected...next time if I have 60 cells, only 50 are selected, even though I used an action command which should select all the cells in that group (in this case being 60). Is there some code I can add to that so this would work correctly?
In case its required, here is the code from the macro:
View 11 Replies
View Related
Apr 24, 2009
I've been doing various searches for past few hours and can't seem to find out if one its even possible, the closet I've found on here is to copy row to another workbook.
My question is I have one excel book called level1.xls and another excel book level2.xls, now in level1.xls I have a row of fields filled in and in level2.xls I have a blank form which for example I would like to try programme in VBA from the level2.xls file to click a button and open automatically level1.xls then grab field "A2" value from level1.xls and place it in level2.xls field "L4" then continue using level1.xls "B2" to level2.xls in field "C3" and then continue down when I add more values A3, A4 so on in level1.xls to the same field in level2.xls L4.
Steve.
View 7 Replies
View Related
Nov 16, 2006
I need to get a macro to select all the data in column "A", sort it in ascending order, omit the blanks if any, then select (highlight) all the data so that another macro can be run.
When I record it, it will only record up to the last row I highlight but the data always changes so there could be more or less.
View 9 Replies
View Related
Mar 27, 2014
I'd like to create a macro to copy data from tables in a workbook named "Survey Template 2014" to another workbook named "Status Report." Basically, I'd like the macro to search through the sheets in "Survey Template 2014" based on the Aircraft Registration No: entered in cell R2 of "Status Report." Once the required sheet is found, I'd like to start copying the contents from the "Description" column from 4 tables (Left/Right Wing Structure, Flight Controls/ Empennage/Doors, Nose/Fuselage and Interior/Passenger environment/Misc) if any data exists. I'd like the data to be copied into C19 (under Tasks Column) of the "Status Report" workbook.
View 2 Replies
View Related
May 23, 2014
make a macro which copies columns B to E from workbook 'Book1' (sheet named database) into another workbook called 'Book2'?,
View 3 Replies
View Related
Jun 10, 2009
I am brand new to using macro in excel. I have a report that is generated every month (looks like sheet 1) and I use that data to create an analysis report (sheet 2). Each month forecast is replaced by actual for the month that just finished, I have tried to use macro recorder to make this more automated as every month I copy the forecast down and the actuals in and then readjust my totals and add in the now 12th months forecast, but I have had no luck.
View 10 Replies
View Related
Nov 18, 2009
I have two workbooks which is attached 1)Daily and 2)Daily-2 i need data of Daily -2 to Daily workbook into relavent sheets not the title row. I have written some code for this but iam unable to make because data sometime is more or less in both the sheets.which needs expertise in macros which iam not.
View 3 Replies
View Related
Oct 16, 2006
I have a one workbook where I put in some data and some calculations are performed. Some of the data calculated I want to keep a running log of. I found some code on how to copy a cell to the next available row on a worksheet, but I want to put it in a totally different file. Also I would like to not have to open the other file up to transfer the data. Is this possible? My idea is to have a command button to push when I'm done entering the data.
View 3 Replies
View Related
Apr 7, 2014
I have two workbook.In 'Entry'Workbook where data is filled up daily in different blank cells.In 'Report' workbook,exactly, I want to pull and update the data .The format is same.Then those changes if possible must be shown in a separate sheet.Since the data is very large,I cannot track where the changes has been made in 'Entry' Workbook'.In order to know the changes in cells,I require this on daily basis.Hence I require two things-
1.VBA Code/Macro for pulling & updating changes to 'Report' workbook from 'Entry'Workbook .And only those changes that should be ignored that has been made by me in 'Report'Workbook
2.Changes made in 'Entry'Workbook must be summarised in a separate sheet in 'Report'Workbook.
[URL] ....
View 1 Replies
View Related