Macro To Merge And Center Varied Range Of Data In Fixed Row
Jun 10, 2014
See attached the example worksheet. I am wondering if there is a way to write a macro that will change data from individual strings within a cell row to merged and centre data for that set of data. The issue is the data in the row will be varied i.e. sometimes there will be 20 x 2013 other times there may be 22 X 2013 etc. however, the data will always be fixed in the same row on the worksheet.
At the moment the best I have is a recorded macro, which really doesn't work too great and I end up fixing it constantly.
When I use "Merge & Center cells with Labels" of a pivot table, It is merging Column labels as well as row labels. Is there a workaround to apply this feature only for column labels and not for row labels.
I'm using the following code (found here: [URL]......) populate dates in row 13 for a dynamic Gantt Chart...
It works perfectly to display daily dates in the mm/dd format. Now I want to have an overarching month/year displayed over the entire range for any particular month by merging and centering the cells above the month's dates the above code populates, and pull in the month/year formatted as mmm-yyyy. I've attached a mock up I did manually to convey the desired result.
I am trying to populate a listbox with data that is of varied formats and I can't seem to do it! I can get the data into the listbox but not change the formats. I have attahed a worksheet to show the problem. Basically, column 2 of the listbox I want to be in hh:mm:ss.0 format and column 4 I want to be in dd-mm-yy. The strange thing is that the listbox does seem to take into account some formating as column 4 is in mm-dd-yy format already but column 2 is just a number.
I have a list of people in column A and a list of Cities that they have visited in column B.
I need to check some of the cities they have visited monthly but don't want to check them all.
I have attached a sheet as an example (this has been scaled down).
The number of cities i want to check for each person varies each month depending on how many cities they have visited.
For example, John has visited 16 cities and i want to check 5 of them. I therefore want 5 random cities that he has visited to appear next to his name at the top. The real list of data is massive so this would be really useful if it is possible.
I have looked at rand but i can't get it to randomly give me more than one city, and i don't understand how to get it to give me say 5 cities one month and say 8 cities the next month purely based on a formula from another cell.
I am attempting to modify VBA code from [URL] .....
The section of the code I want to modify is below dealing with importing selective text. The original function returned a "False" if the line contained a keyword specified in the Array function. I have reworked it so that it shows a "True" if the line contains a keyword specified in the Array function.
My only problem is that it only does it when the keyword appears in the beginning of the line, as it uses the "Left" operator in looking at line. How do I configure the function so that it returns a "True" if the keywords appears anywhere in the line?
I have rather large Excel file that spans around 245 columns & has multiple users responsible for certain columns. Columns are chunked to provide data about a specific group. Every 72 hours, I need to provide to managers what’s currently on this file in a specific summary format.
I’ve recorded a macro that gets me half way there. Here’s where I’m clueless. After my macro deletes unnecessary columns, what remains are the columns for “Main Data” group + each of the 5 “Business” groups (Investors, Lawyers, Credit, Finance, and Support) which would have identical column headings.
(1) Name (2) Address (3) ID# (4) Control#
Furthermore, for each of the 5 “Business” groups, there are 9 slots (ie- a user can enter up to 9 unique entries for a particular group.)
Example- The Investor group contains 9 slots. Each slot will contain the 4 columns mentioned above. So there are 46 slots in total – 1 for Main Data, 45 (5 groups x 9 slots) for Business groups.
MY PROBLEM: I need a macro to now cut & paste all data from each of the 45 Business groups slots & then paste at the bottom of the MAIN DATA slot.
The final file would be 4 columns (as listed above) wide. Data from each of the 45 business group slots would be one below the other- all of it underneath the data in the Main Data group.
I attempted to record a macro where I’m copying a section’s data range starting from row2 to row4000 (I know there will never be 4000 entries. I did this just to ensure that all future data would be captured) then pasting that after the last entry in the Main Data.
Example- I’d copy data from Investor1 slot(starting at column E2-H2) & go about 4000 rows down. Then I’d press CTRL+Down Arrow key in column A & then click the down arrow one time to take me into 1st empty cell where I would paste my copied data. I was going to repeat this process for the remaining 44 slots.
I’ve added some extra entries to test the macro & the problem is that the recorded macro is pasting data in specific cell location in column A instead for looking for the 1st empty cell in column A & then pasting the copied data.
So far I've gone thought the net & tried to paste in a few VBA posts/tips that I thought would work. Here's what I have so far from tinkering around. I need someone to tell me what to replace the xxxxxxx line with. This would be the language to tell Excel to paste copied data range into the first blank cell in column A. I've gone thought the net & tried to paste in a few VBA posts/tips that I thought would work.
Here's what I have so far from tinkering around. I need someone to tell me what to replace the xxxxxxx line with. This would be the language to tell Excel to paste copied data range into the first blank cell in column A.
Sub transposedata() Sheets("ConsolidatedYTDReport").Select Range("E2:H4202").Select Selection.Copy XXXXXXXXXXXX ActiveSheet.Paste End Sub
I have been using the following code to fill data down a col. For example if a1=blue and a5=green and a7=red. The macro will fill a1(blue) down to a4, then take a5(green) to a6, then a7(red) etc.
Sub Filldown() If ActiveCell.Text = "" Then MsgBox "please start with a non-empty cell" Exit Sub End If For Each x In Selection.Cells If x.Text = "" Then x.Value = x.Offset(-1, 0).Value End If Next x End Sub
code works great, but I was hoping it could be changed so that instead of filling the data down it would merge the data down. So, in the example, a1:a4 would be merged leaving the word blue, a5:a6 merged, and a7:etc would be merged. Is this possible?
I am trying a macro to merge cell without losing the data until I find a next cell with the data - This merging should be pertain only for the column selected. Is it possible to write a macro and preform this activity.
I have data like Below Mentioned in column A and Column B.I Want to Merge and Center the Data in Column based on column A.
For example; I want to Combine the Cell i.e b2 and b3,B4 to B7,No Need to merge B8 Because A8 have a Same name But Differnet City. and so no.
I need a Macro.I have 6000 data in one sheet.I have 18 Sheets like this
DEALER NAME A M MOTORS MALLAPURAM8 A M MOTORS MALLAPURAM AALIANZ AUTOMOBILES NEW DELHI7.35 AALIANZ AUTOMOBILES NEW DELHI AALIANZ AUTOMOBILES NEW DELHI AALIANZ AUTOMOBILES NEW DELHI AALIANZ AUTOMOBILES Noida15 ABHARAN MOTORS UDUPI7.88 ABT MARUTI CHENNAI7.89 ABT MARUTI CHENNAI ABT MARUTI CHENNAI ABT MARUTI CHENNAI ABT MARUTI CHENNAI..................
I'm having to run at low resolution on a sheet currently, so I'm using a zoom/center routine to make the dropdown lists visible for selections.
Issue I have is how do I select cell A1 after my error handling and exit routine properly. I couldn't get it to work without trying to select cell A1 before I would make a dropdown list selection. For now I am just running a separate macro to select a1 tied to a pushbutton as a temp fix. Code is attached.
Private Sub Worksheet_SelectionChange(ByVal Target As Range) Dim lZoom As Long Dim lZoomDV As Long Dim lDVType As Long lZoom = 57
In the attached file, i want to select the range from cell B8 (which is fixed), to used range i.e. till Cell F18 (but the problem is, cell F18 is not fixed). Last used row or column can change. I want to do it by using VBA.
I am still trying to develop a macro that will copy and paste a set of formulas into a dynamic destination range. I have included a worksheet that shows what I am trying to do. Basically when using AutoFill I need the columns of the destination range to be dynamic based on the number of rows in another sheet.
Range Macro - looking to create a simple macro to highlight a colum range from any location in column A that the cursor has landed on to the fixed location "A3". Example: If I am on A34, then the macro would highlight A34:A3. I can then edit the format in that range. Idealy, I could search on Column A first for a given text, then run the above macro to highlight every cell between that given text and "A3".
Im doing a project and Ive heard that previously, this was done by copying and pasting which took countless man hours to do.
I want to make automated reports of call center data per day per agent. I would like for it to exported into a single excel worksheet with a tab for each Agent, listing the stats per day. What program would be the best to accomplish this feat. I was thinking of importing the information to access to create to muniplulate the information in a one click fashion. but im not sure if i could get the data back to excel.
I need to figure out a formula for cell F17 that will calculate a percentage change only for the months that have data in 2009. The way it is set up right now I have to go in every month and change the cell reference of the formula to include the latest data. Since the 2008 data is totally populated the formula gets messed up if I include the months of 2009 that have not yet occurred.
How can I select sheets in a workbook based on the premise that the sheetname does not have the letter "Q" in it? New to forum, so apologies if format is not kosher. I have a group of 50+ workbooks which are all set up in the following format:
-Contains 30+ sheets. -Sheet names are varied, but follow a pattern. I try to keep the sheet names consistant on all workbooks so that it is easier to reference, but other users make this impossible. -However, I managed to keep two things consistant: There are two categories of sheets. In one group all sheetnames have a "Q" in them and in the other group all sheetnames DON'T have a "Q" in them.
Here is my problem: I need to run a macro to perform retative tasks on the GROUP OF SHEETS WITHOUT A "Q". To begin the macro I need to select these sheets and copy them to a new workbook, but since the actual sheetnames are varied, I am having trouble coming up with a flexible way of selecting sheets. The closest I have come is using a IF ... LIKE ... THEN statement, but I can only get it to work to select the sheets with a "Q" in the name and not the opposite.
How can I shift the range of cells I want to calculate an average from? For example I want to get the average of cells A1 to A10, so =AVERAGE(A1:A10) And next I want to get the average of cells A11 to A20, so =AVERAGE(A11:A20). But I don't want to manually change the data or delete rows all the time.Is it possible to do something like: =average(A1+10:A10+10)??
I have the following macro that runs every time the system clock's second changes to 07 seconds. I however want it to stop running at 09:47 am. I have the code to stop the timer also (given below) but I am unable to stop the loop at 09:47 am. How do I do that?
VB: Sub Timer()With Workbooks("book3.xlsm").Sheets("Sheet1") Range("B10:E10").ClearContents End With Application.OnTime DateAdd("n", 1, CDate(Left(Now, Len(Now) - 2) & "07")), "Timer" End Sub
I am trying to create a Dashboard in excel (2010) using tables/pivot tables to build it. The data I am bringing into excel has these key fields of data: cost center+cost center description, general ledger account+general ledger account description, and YTD amount.
My problem is the data is from an external source report and the report has subtotals built in at cost center, and the report's format of subtotaling puts the cost center first and then the general ledger accounts below. There is no formula value in the cell that has the subtotaled amount and the number of general ledger accounts can vary depending on whether there has been general ledger activity.
I want to take this format: July YTD Cost Ctr 1050 XYZ$6.00 625110 Supplies$2.00 650150 Postage$2.00 650550 Fees$2.00 Cost Ctr 1052 ZZZ$4.00 670500 Pens$2.00
and have it look like this Cost CenterCost Center DescrGL AcctGL Acct descYTD Amt 1050 XYZ 625110 Supplies $2.00 1050 XYZ 650150 Postage $2.00 1050 XYZ 650550 Fees $2.00 1052 ZZZ 679200 Pens $2.00
Besides manually doing data moves and assigning a unique sort sequence number to keep the records together, how else can I quickly move my cost centers to a new column and keep the cost center with the gl account and $amount?
For a sheet that many non-expert users will use on different systems I need a macro that let's them save, print and send the results of their work. So I made a macro that makes a copy of only 1 sheet of the workbook and saves it with a given name to a given location. The problem is that I want a location prompt to ask the user where they want the file saved, while giving/suggesting them a fixed filename. A lot of different users will make and use their sheets so I need a certain naming policy to manage all the files. (date, location, etc)