Home |
Search |
Today's Posts |
|
#1
![]()
Posted to microsoft.public.excel.programming
|
|||
|
|||
![]()
Hi Nijan
put the following code in a module of your workbook: ----- Sub insert_cc() Dim rng As Range Dim row_count Dim column_no Dim cost_center Set rng = Selection With rng If .Columns.Count 1 Then Exit Sub column_no = .Column For row_count = (.rows.Count + .Row - 1) To .Row Step -1 If Cells(row_count, column_no).Value < "" Then cost_center = Cells(row_count, column_no + 1) ElseIf Cells(row_count, column_no + 1).Value < "" Then Cells(row_count, column_no).Value = cost_center End If Next End With End Sub ---- Now do the following: - select your column which has to be filled (e.g. your cells in column A) - start this macro It requieres that all subtotals have an entry in column A (so in your example the last row has to contain an entry for the last cost center) -- Regards Frank Kabel Frankfurt, Germany Hi I wonder if you can help me. I am attaching an Excel 2000 file that shows and extract from our Financial System. Basically there are 3 columns- Cost Centre, Accounting Codes and £. There is a cost centre name (in red) in the subtotal row in the Accounting Codes column. What I would like to do is to write a macro that will search the column "Accounting Codes" for the cost centre name and then paste that name in the Cost Center column for each of the rows that belong to that cost centre up to the subtotal line. Thank you in advance Regards Nijan Attachment filename: test.xls Download attachment: http://www.excelforum.com/attachment.php?postid=450283 --- Message posted from http://www.ExcelForum.com/ |
Reply |
Thread Tools | Search this Thread |
Display Modes | |
|
|
![]() |
||||
Thread | Forum | |||
Colon at the end of excel file name(ex: problem.xls:1, problem.xls | New Users to Excel | |||
Problem viewing Excel 2003 Pivot Chart fields in Excel 2007 | Charts and Charting in Excel | |||
Weird problem with Excel 2000...Worksheets disappearing in a shared Excel file | Excel Discussion (Misc queries) | |||
Started out as an Access problem. Now an Excel problem | Excel Discussion (Misc queries) | |||
EXCEL FORMAT PROBLEM WHEN SENDING EXCEL SHEET AS MESSAGE BODY IN . | Excel Discussion (Misc queries) |