Reply
 
LinkBack Thread Tools Search this Thread Display Modes
  #1   Report Post  
Posted to microsoft.public.excel.programming
external usenet poster
 
Posts: 1
Default Excel VBA problem

Hi
I wonder if you can help me. I am attaching an Excel 2000 file tha
shows and extract from our Financial System. Basically there are
columns- Cost Centre, Accounting Codes and £.
There is a cost centre name (in red) in the subtotal row in th
Accounting Codes column. What I would like to do is to write a macr
that will search the column "Accounting Codes" for the cost centre nam
and then paste that name in the Cost Center column for each of the row
that belong to that cost centre up to the subtotal line.

Thank you in advance
Regards
Nija

Attachment filename: test.xls
Download attachment: http://www.excelforum.com/attachment.php?postid=45028
--
Message posted from http://www.ExcelForum.com

  #2   Report Post  
Posted to microsoft.public.excel.programming
external usenet poster
 
Posts: 3,885
Default Excel VBA problem

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/


  #3   Report Post  
Posted to microsoft.public.excel.programming
external usenet poster
 
Posts: 1
Default Excel VBA problem

Hello Frank


I tried your VBA code and applied it as you suggested.

It worked perfectly and gave me exactly the solution that I needed.

Thank you very much. Your help has been much appreciated.

Kind Regards
Nija

--
Message posted from http://www.ExcelForum.com

  #4   Report Post  
Posted to microsoft.public.excel.programming
external usenet poster
 
Posts: 3,885
Default Excel VBA problem

Hi Nijan
thanks for the feedback. Glad to be of some help

--
Regards
Frank Kabel
Frankfurt, Germany

Hello Frank


I tried your VBA code and applied it as you suggested.

It worked perfectly and gave me exactly the solution that I needed.

Thank you very much. Your help has been much appreciated.

Kind Regards
Nijan


---
Message posted from http://www.ExcelForum.com/

  #5   Report Post  
Posted to microsoft.public.excel.programming
external usenet poster
 
Posts: 102
Default Excel VBA problem

Just paste this formula into all your blank cells of Column A that are next to data in B column.

=INDEX(B4:$B$1000,MATCH("*bank*",B4:$B$1000,0))

Increase the 1000 if your rows extend further.
First select your range by selecting A3 then Control + *
Use F5, Special Blanks to select your cells.
Paste the formula to the formula bar, then press Control + Enter.
No VBA code is necessary, although if you must have it, just record the above to see it.


Regards Robert


"nijan_shah " wrote in message ...
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/



---
Outgoing mail is certified Virus Free.
Checked by AVG anti-virus system (http://www.grisoft.com).
Version: 6.0.593 / Virus Database: 376 - Release Date: 21/02/2004




Reply
Thread Tools Search this Thread
Search this Thread:

Advanced Search
Display Modes

Posting Rules

Smilies are On
[IMG] code is On
HTML code is Off
Trackbacks are On
Pingbacks are On
Refbacks are On


Similar Threads
Thread Thread Starter Forum Replies Last Post
Colon at the end of excel file name(ex: problem.xls:1, problem.xls financeguy New Users to Excel 2 January 15th 10 01:15 AM
Problem viewing Excel 2003 Pivot Chart fields in Excel 2007 ronny B Charts and Charting in Excel 1 October 24th 08 10:08 PM
Weird problem with Excel 2000...Worksheets disappearing in a shared Excel file BrianL_SF Excel Discussion (Misc queries) 2 October 10th 06 08:27 PM
Started out as an Access problem. Now an Excel problem RobertM Excel Discussion (Misc queries) 2 April 26th 06 07:30 PM
EXCEL FORMAT PROBLEM WHEN SENDING EXCEL SHEET AS MESSAGE BODY IN . P.S.Sodha Excel Discussion (Misc queries) 0 April 2nd 05 01:53 PM


All times are GMT +1. The time now is 07:18 PM.

Powered by vBulletin® Copyright ©2000 - 2025, Jelsoft Enterprises Ltd.
Copyright ©2004-2025 ExcelBanter.
The comments are property of their posters.
 

About Us

"It's about Microsoft Excel"