Reply
 
LinkBack Thread Tools Search this Thread Display Modes
  #1   Report Post  
Posted to microsoft.public.excel.programming
C C is offline
external usenet poster
 
Posts: 61
Default Auto format sheet

I have a spreadsheet that I continously have to format. It is a data dump
from another application. It could be any number of rows and any number of
columns. I need a macro that will look at column A and format B based on
the number in Column A. So if Column A is 2 then indent Col B 5 spaces, if
Col A is 3 then indent Col B 10 spaces, if Col A is 4 then indent Col B 15
spaces. Also if Col B is Bold then shade row Gray.

Thanks in advance for your help.
clv
  #2   Report Post  
Posted to microsoft.public.excel.programming
external usenet poster
 
Posts: 1
Default Auto format sheet


The following code should work:


Code:
--------------------


Sub reformat()
Dim i As Long
For i = 1 To Range("A" & Rows.Count).End(xlUp).Row
If Cells(i, 1).Value = 2 And Cells(i, 1).Value <= 4 Then
Cells(i, 2).Value = Space(5 * (Cells(i, 1).Value - 1)) & Cells(i, 2).Value
End If
If Cells(i, 2).Font.Bold = True Then Cells(i, 2).EntireRow.Interior.ColorIndex = 15
Next i
End Sub
--------------------


--
Paul

- Paul
------------------------------------------------------------------------
Paul's Profile: 1697
View this thread: http://www.thecodecage.com/forumz/sh...d.php?t=192571

http://www.thecodecage.com/forumz

  #3   Report Post  
Posted to microsoft.public.excel.programming
C C is offline
external usenet poster
 
Posts: 61
Default Auto format sheet

Paul,

This is perfect. Thank you so much.

clb

"Paul" wrote:


The following code should work:



Code:
--------------------



Sub reformat()
Dim i As Long
For i = 1 To Range("A" & Rows.Count).End(xlUp).Row
If Cells(i, 1).Value = 2 And Cells(i, 1).Value <= 4 Then
Cells(i, 2).Value = Space(5 * (Cells(i, 1).Value - 1)) & Cells(i, 2).Value
End If
If Cells(i, 2).Font.Bold = True Then Cells(i, 2).EntireRow.Interior.ColorIndex = 15
Next i
End Sub


--------------------


--
Paul

- Paul
------------------------------------------------------------------------
Paul's Profile: 1697
View this thread: http://www.thecodecage.com/forumz/sh...d.php?t=192571

http://www.thecodecage.com/forumz

.

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
Auto copy cell data from source sheet to another wrkbook sheet IVLUTA Excel Programming 2 June 2nd 09 05:07 PM
Auto Copy/autofill Text from sheet to sheet if meets criteria Joyce Excel Discussion (Misc queries) 0 November 20th 08 11:05 PM
ignore auto format after applying a custom format?? jigglepop Excel Discussion (Misc queries) 0 April 2nd 08 04:17 PM
Help: auto-copy entire rows from 1 sheet (based on cell criteria) to another sheet. bertbarndoor Excel Programming 4 October 5th 07 04:00 PM
Excel Auto-Format cell to email format Please Help Me Excel Discussion (Misc queries) 1 March 23rd 06 05:15 PM


All times are GMT +1. The time now is 12:24 PM.

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

About Us

"It's about Microsoft Excel"