Copying Cell Based On Number In Other Column
Aug 13, 2009I have a name in cell A1 and a number of 20 in cell B1. Is there a function to copy the name in cell A1 the number in cell B1 (20 in this case) times into column C?
I have a name in cell A1 and a number of 20 in cell B1. Is there a function to copy the name in cell A1 the number in cell B1 (20 in this case) times into column C?
I have :
A1 = "Banana"
A2:10 = blank cell
B1 = xxxxxxx (always 7 digits) (number)
B2:B10 = xxxxxxx
How to fill the range of A2:A10 with "Banana" only if the value in Column B is having a value (or not blank)?
The second one is, how to delete entire row if the value in column B is text?
I have been trying to format the rows on this sheet to color scale red based on the number of repeat text strings in Column E. Referring to the attached example sheet, '321/312.2/321.3' appears the most times and the goal is to color code the rows it appears in the deepest shade of red, then the next highest occurring string would shade the rows it appears in a lighter shade, etc, in descending order. Our team currently does this across multiple sheets manually everyday and it would be a real time saver if we could get excel to do this automatically.
View 14 Replies View RelatedPlease see attached sample worksheet. Column A will be generated by the user manually.
I'm looking for a way in VBA to have A1:D20 in Sheet2 copied and pasted in the "Bank Reconciliation" Sheet based on how many "Markets" there are in Column A. Then, once that's complete to have A22:D30 (the smaller box in Sheet2) copied and pasted directly below those results.
I have what the macro would hopefully generate to the right in "Bank Reconciliation" (B6:E54) as an example. So if there's a market in A1, copy and paste the box to B6. If there's a market in A2, copy and paste the box directly below the first (B26) etc. etc. until it's done, then paste the smaller box directly below whatever the macro generates.
Book2.xlsx
I am using MS Excel 2007 and I am trying to create a macro which will copy column E and paste the data in column E to the bottom of column D. However each week the amount of rows in these column with vary, they will always be the same amount of rows in column E as in column D but there may be 20 rows one week and a 100 rows the next.
The formula I currently have is below but this will only work for a specified number of rows. How I could change this to work for any number of rows?
Code:
Sub IPT()
'
' IPT Macro
'
'
Range("E1").Select
[Code] .....
I have data as follows.
In the first column name of the month is specified.And in the third column of the same row day is specified.And followed by some data in rest of the columns and rows.
I need to copy the data from the presant sheet to a new sheet based on some conditions.
first need to search for the row where the word "MONTH" is there.if it is found then in the same row third column need to be checked for the day like "MONDAY" or "TUESDAY".If it is monday then need to copy 6*8 array of data i.e. (6 rows and 8 columns) into a sheet "MONDAY".if it is TUESDAY then 5*8 array data into a new sheet TUESDAY.And the search should be continued till the end of sheet.
I have a spreadsheet with data in a1:p100 and i'm trying to find a macro that anytime the cell contents change in either column B or Column F it copies the entire row to another tab in the spreadsheet.
View 9 Replies View RelatedI'm trying to copy cells from a column in one workbook to cells in a column in another workbook based on what's in a header column.
Such as
Original workbook
Mat Qty
A 1
C 3
D 2
E 4
G 5
Total 15
Target workbook becomes
Mat Qty -> Mat Qty
A -> A 1
B -> B
C -> C 3
D -> D 2
E -> E 4
F -> F
G -> G 5
My code so far (which might not be worth reading) is:
Code:
Sub CopyColumnToWorkbook()
Dim sourceColumn As Range, targetColumn As Range, sourceColumnValue As Range, targetColumnValue As Range
Dim mySourceCell As Range, myTargetCell As Range
[code].....
I'm getting a runtime error ('1004'. Application-defined or object-defined error) on the Copy statement within the If sttement.
I have a master data sheet with the structure as below: I need a few of the columns (i.e. not all) to be copied to another (filter) sheet (starts from Row 20 say). The "notes" column should be fed back to the master list. If the condition changes in the master list, the entire row (including the data entered in notes) should be removed on the filter sheet.
The filter sheet structure is as below:
I initially used Index, Small, Countif to pull data to the filter sheet but could not "input" into the cells as they all held formulas in order to copy to the new sheet.
I have a column that is made up of postcodes, lat, long, eastern, northern data eg: SK10 5BA, 53.291013, -2.096675, 393652, 377121
And I want to end up with a column containing the lat (53.291013) and another containing the long (-2.096675).
I have worked out to use formula's to remove a certain number of characters from the left and right of the cell, but the challenge here is the postcode at the begining of the data, can be varying in length.
know of a formula that will let me copy a certain number of characters within the cell, but counted from the right, as the eastern and northern numbers are always the same length.
I'm trying to write a code that calculates 2nd column based on 3rd column's number or vice versa based on the condition set on the 1st column. Below, there are two procedures. "SimpleCalc" and "SimpleCalc2". I first wrote SimpleCalc2, but it isn't working, so I worked around the error by writing SimpleCalc, which selects a cell and moves around by offset. I personally find it hard to read and error prone as I develop more logic around it.
I'm trying to develop more function based on this code, so I need to make it neat and flexible. what I'm doing wrong in SimpleCalc2? Or do you have any suggestion to improve the code "SimpleCalc"? I'm using Excel 2003.
Sub SimpleCalc()
Dim SimpleMethodRng, SimpleMethod As String, i As Integer
ActiveWorkbook.Worksheets("Dashboard").Range("P5").Select
SimpleMethodRng = ActiveWorkbook.Worksheets("Dashboard").Range("N5:P12")
For i = 1 To 8
SimpleMethod = SimpleMethodRng(i, 1).........
I have the following sample data set and I'm trying to return the appropriate column header based on criteria (i.e. DDD) and a number value which will be somewhere within the range of the table. In example below, the value returned should be Header 2 because the value is greater than those in Header 1 column (range H9 to L26).
Here's data table:
CriteriaHeader 1Header 2Header 3Header 4
ZZZ5.0015.0050.00130.00
ZZ5.0015.0050.00130.00
Z5.0015.0050.00130.00
YYY5.0015.0050.00130.00
YY5.0015.0050.00130.00
Y5.0015.0050.00130.00
DDD5.0015.0050.00130.00
DD5.0015.0025.0075.00
D5.0015.0020.0065.00
RRR5.0015.0015.0045.00
RR2.5010.0010.0030.00
R1.503.0010.0025.00
UUU0.751.505.0020.00
UU0.751.505.0020.00
U0.751.505.0020.00
P0.751.505.0020.00
T0.100.105.0018.00
CriteriaNumberValue
DDD10.00Header 1>>>=INDEX($I$9:$L$9,MATCH(I29,INDEX($I$10:$L$26,MATCH(H29,$H$10:$H$26),)))
I am trying to use VBA to move data from one column to another while using values of a third column as a reference for where each value in the first column should be moved to in the second. I will try to explain as best as possible, currently I have a macro that copies from one column to the required but due to the irregular spacing of the data it results in the data not matching with the data its being copied into.
Say I have Three columns A, B and C. I have a range of data in column A say dates that have irregular amounts of spacing between them. Column B is empty. Column C contains Data that is again spaced out irregularly and not in line with that of A. The value of column C cells is just identical values. Now the aim is to move the values from column A in the order which they are listed and place them in Column B next to each value in Column C. So say the repeated value in column c is EXAMPLE then everytime EXAMPLE appears in column C i want to move one date from column A into column B next to this EXAMPLE value, in order which it appears in column A. So the first date will move next to the first EXAMPLE value and the second date which appears next to the second EXAMPLE and so on and so on until it reaches the end of the sheet.
My thinking was placing the A column data in an array and doing some sort of sort.
I have written a code for a cell in excel but it only works for the row it is on. I want to copy this code down the column (until reaching an empty row) will cells refernced in the code changing accordingly (just as if i had written the code in the cell and dragged it down a column). A sample of the code I have written is given below.
Private Sub Worksheet_Change(ByVal Target As Range)
If Range("E4").Value = "L" Then
Select Case Range("D4").Value
Case 43
Range("H4") = "=2*G4"
Case 48
Range("H4") = 60
End Select
I am trying to save an excel sheet to .csv format with the following macro:
[Code] ......
The following part of the code needs to be modified so that the commas appear correctly in .csv file even for null values for any given column.
[Code] .....
I have attached the Sample Sheets. Source sheet and the Result sheet. The Result sheet doesn't provide the required result. Some data are missing and unwanted commas have been added. How to correct the logic in the above piece of code.
Attached File :
Result Sheet.csv
Source.xlsm
With reference to attached file. I want to copy column D&E for 'n' number of times of value based on B1. If value in cell B2 is 0 then hide cell D&E and if there is any other value, excel to copy E&F to next column (leaving one column blank after each paste).
A
B
C
D
E
2
Product A
Price
VTA-2001
999
VTAA-2001
1299
XMV-1001
1000
I have a workbook called "Staff Planner". I need to check Columns C to I in Sheet "Plan" to firstly find text in a red font, and then copy this value to Sheet "Useage" in Column K. (So, search C1:I1, find red font, copy contents of cell, paste value to K1). I then need to repeat this with blue font/value to H1, green font/value to E1, and finally pink font/value to B1
View 9 Replies View RelatedOn sheet "Create Package" in cell "AA14" I have a value (lets say 2).
I want it to go to sheet "Samples" and insert a number of rows equal to the value on sheet "Create Package" cell "AA14" (so 2 rows)
I have a header row in row 1, so I would like it to insert the designated number of rows beneath that.
Then I would like it to copy a designated number of rows (based off of the "AA14" value, so 2) from the "Create Package" sheet starting at row 66 and then paste special values into the new rows that were inserted on sheet "samples".
I am trying to copy two cells from one worksheet to another in the same work book based on the value in Column B of one of the sheets. This is just a building block to a larger script I am going to create.
Below is my attempt but I keep getting an error at Range(Cells(x, 3)).Select.
I am wondering if it possible to automate the copying of data from particular cells, based on a value in a different cell, into a different format.
So to go from this simplified table:
AB1NameLevel2Arthur2a3Briony3c4Catherine3b5David3a6Edward2a7Felicity3c8George3c
to something like this:
FGHI12a3c3b3a2ArthurBrionyCatherineDavid3EdwardFelicity
4
George
At the moment I do it all manually, and it takes forever. I am sure there must be a simple way of doing it. I am using Excel 2003, but could work in a newer version if required.
I'm sure there is an easier way than copying and pasting each individual cell from one spreadsheet to another. Is there a way I can define a batch of cells (city, state, phone #) and copy them into the other spreadsheet so I don't have to do each cell individually?
Here is a picture to show what exactly I am trying to do.
SS.PNG
Also, the cells that belong in the same column and row on one spreadsheet are equal distance from each other throughout the other spreadsheet that has all the info in 1 column.
I have numbers in b2 to b5 say
10
22
35
50
I have numbers in c2 to c5 say
1000
1580
3000
45000
I have numbers in cells d1 to kq1 (1 to 300) d1=1, e1=2, f1=3 and so on
What I want to do is:
In D2 through to kq2 it puts the number in to the cell that correspnds to a multiple of the number in b2.
That would put 1000 in cells m2,w2,ag2,aq2, ba2 and so on
In D3 through to kg3 it it puts the number in to the cell that corresponds to a multiple of the number in b3
that would put 1580 in cells y3,au3,bq3,cm3,di3 and so on
I have Sheet with 40 employees who each proposes their work schedule, so I have to give each Employee access to the same sheet and want highlight and unlock only those cells that specific employee can use.
Each employee has to login from a drop-down (sourced from Sheet.Employee Master), so their unique Employee Number is in "A13" of Sheet.LOGIN
Can I identify the ROW number and then use that ROW number in a macro to highlight and unlock specific Range of Cells in Sheet.PROPOSED SCHEDULE?
---where "Sheet.LOGIN("A13") = (the value in the cell Col A:"row" of Sheet.PROPOSED SCHEDULE)
I have attached a scaled down version of the Workbook.
Following code is scaled down-- this is for Employee 02 who appears on ROW 16 of the sheet. (macro is same for each employee, just uses a different row)
I am trying to come up with a macro that selects values from one sheet and inserts them into another sheet. The number of values will change each time based on the user's entry, as well as the number of times that each entry should be pasted.
For example:
Entry: X | Y | Z
Number of Times to be Inserted to New Sheet 3 | 2 | 1
Result:
X X X Y Y Z
I have spent a while trying to figure it out, however the best I can come up with is using an array, but I can only get one value from the array to paste multiple times:
(*Note: In my testing, I didn't insert into new sheet or set up the array to handle different values, I was just trying to get the basic idea to work)
Dim A(1, 3) As Variant
A(1, 1) = Range("C3").Value
A(1, 2) = Range("D3").Value
A(1, 3) = Range("E3").Value
[Code].....
I have a list in Excel with several hundred 8 digit ID numbers in column D. Column C contains the total number of hours the student employee worked. Column E needs to calculate using two different equations depending on if the ID number in column D is a manager's. If the ID number is an employee the total hours worked is divided by 8. IF the ID number represents a manager the total hours worked is divided by 4. I've attempted this by using an array for the manager ID list and also using VLookup without success.
In essence I need to loop through column D, check which type of ID number is present, and then enter the correct formula in column E.
I need to cocatenate anything between and including column 4 and col (unkown until macro is run)
is there a way to do this?
Basically need to add all the cells from 4th column to whatever col is. Example if col = 12
then I need columns 4 to 11 all rows together
I am using the following to autofilter a column based on a month number
Worksheets("Data").Range("$A:$M").AutoFilter Field:=8, Criteria1:=Month(tempmon)
tempmon contains the month number (e.g 9 for september)
when I run this it filters but tempmon is equaling 1 when I know it is set to 9
i have tried
Worksheets("Data").Range("$A:$M").AutoFilter Field:=8, Criteria1:=Month(9)
I have a column say column B for example that has a list of dates in the format dd/mm/yyyy. I would like a summary at the top of the columns to state how many dates there are for the current month. But I wondered if this was possible based on the TODAY() function or similar. Thus the user would not have to change anything.
So for example at the start of the month it may state 14. Half way through the month down to 6 and at the end of the month 0 for example.
I have formulas in cells B8:F8. I need to copy these formulas down based on the number of rows in column A that has data. The data in column A will vary based on user input.
View 2 Replies View RelatedI get this work a lot and am looking for a much more effective way of working the dataset,
I have numbers like 1.1, 1.2, 1.3 and so on.......
These come under criteria like (1) = 1.1, 1.2, 1.3 and so on.....
I am look for an automated way of doing a count of any number that falls under this criteria, so I want to count based on criteria (1) it would count all 1.1,1.2,1.3 and so on as one count.
I am attaching a sample document to see how it is laid out. [URL] .....