I am trying to create an Excel macro that will take raw data (from an Excel Worksheet) and make worksheets organized by month within that Excel file. For example, I have a date column with data in the following format MM/DD/YYYY HH:MM:SS and I want the macro to create new Excel worksheets for each month. So by the end of the process the months (say Jan-March) are each individual worksheets and the raw data is sheet is still intact (unchanged).
I am fairly new to writing Excel macros so any help would be appreciated.
The best thing you can do when getting started with excel macros is to record what you want to do and then inspect and refactor the code that excel generates for you. In your case, go Tools;Macro;Record new macro. Then create a sheet. Then choose the first cell containing a date and modify its value. Then select the row and copy it to the new sheet. Inspect the macro (Tools;Macro;Visual basic editor) and you should see the bones of inserting a new sheet, getting the value of a cell and copying a row of data.Now throw in a CDate function to turn your date cell into a date, a DatePart to extract the month and a for loop to go through your source data and you'll be off to a good start!
Related
I am attempting to transpose data in multiple columns from different sheets in a workbook into rows in another sheet (within the same workbook). I am attempting to make this code dynamic. For example, once the latest month closes, the code will pull the updated numbers-there are blank cells after June (so Cell D274 is blank). Below is the code I have tried and a screenshot to visualize what I am attempting to do. Any help would be greatly appreciated.
I have 1 particular excel sheet and a bunch of other excel workbooks with raw data.
That particular excel sheet works as a template for data analysis, so I copy-paste that sheet to a raw-data excel workbook to undertake analysis on that raw data.
Problem is that when I'm pasting the template sheet to the others, I need to change the reference every single time because the analysis is done referencing the sheet that contains row data. Also, sheet name is unique on
every workbook.
I tried the below VBA code but it's attached to the workbook rather than the template sheet itself, so I can't just create a copy of that sheet to a raw data excel workbook.
Function NxtShtNm() As String
Application.Volatile
NxtShtNm = ActiveWorkbook.Sheets(ActiveSheet.Index + 1).Name
End Function
Could I get any advice on above?
Thanks!
I'm attempting to design a macro to simplify the update process for my company's order tracking, and I'm struggling with relative references. I'm using Excel 2010.
what I need the macro to do: Find a given part number on one workbook, and use the row number of to update formulas in a a second workbook.
In more detail:
Where |Y|= column letter of original spreadsheet, |X|= row number of original spreadsheet, and |X^|=Row number of ‘All Inventory.xls’
There are 4 separate spreadsheets I would need to run the macro from (It’d be a lot easier if I could have the 4 as separate pages on one spreadsheet, but unfortunately, my boss is 60 and is a bit fuzzy on how excel works.)
The spreadsheet ‘All Inventory.xls’ is not in table form, and I can’t convert it to one. (the guy who runs inventory is very fuzzy on how spreadsheets work, approximately five years from retirement, and about as friendly as a snapping turtle.)
When run from cell |Y||X| in a table:
Copy content of the cell in table column ‘Part #’ in the same row – structured reference [#[Part #]]|X|
Paste content of cell ‘[#[Part #]]|X|’ into Find/Replace
Switch to spreadsheet ‘All Inventory.xls’
Hit ‘find next’ – will land on cell C|X^|
switch back to original spreadsheet
return to original cell |Y||X|
type “=’[All Inventory.xls]Sheet1’!$E$|X^|”
go to cell |Y+1||X|
type “=’[All Inventory.xls]Sheet1’!$G$|X^|”
go to cell [Y][X+1]
End macro
I've tried recording this directly, while using relative references. Excel didn't like that. I'm not sure where to go from here.
I admit to not being very technical and my limit up to now has been using paste links to connect data between sheets. I now have a requirement I cannot figure out.
I have 2 workbooks I wish to automate sharing data between.
Workbook 1 contains multiple rows of data manually entered.
I need a button against each row so when it is pressed data from certain cells on that row in Workbook 1 are transferred to cells within a worksheet in workbook 2
I would be very grateful for any guidance on how to achieve this.
Many thanks!
Though you can deploy VBA to achieve this, but the same is also possible with simple formula like.
=[1.xlsx]Sheet1!$A$1
Lets say you have two workbooks 1.xlsx and 2.xlsx and you want sheet1/column A1 value from 1.xlsx to be auto populated in sheet1/column A1 in 2.xlsx, you can simply link it with a formula like =[1.xlsx]Sheet1!$A$1 in second workbook 2.xlsx.
So as soon as some entry is done in first cell, second cell is auto populated
However if you are looking only for vba solution do write back
I copied data from a callmanager. i want to use the data it displays in the spreadsheet which is hh:mm:ss. But in the input box in the top it shows other data (date and time which i think display the date and time of recording of the data). When I try to use to manipulate the hh:mm:ss in the spreadsheet it keeps using the data in te input box. How can I tell excel to use the data displayed in the spread sheet and remove the data in the input box?
thanks in advance!
I don't know of a specific method to do it in excel only, but what I've been using so far for instances like this is:
Copy the column having those values and paste into notepad,
Insert a new column in the worksheet and format it as Text,
Copy everything from the notepad and paste into that new column.
This might be a little awkward, but it works for me ^_^