PC Review


Reply
Thread Tools Rate Thread

Adding Formatting to Code

 
 
DaveH
Guest
Posts: n/a
 
      16th Feb 2009
I seem to be having brain lock and cannot figure out how to add additional
formatting to my code.
Code below.
I'm looking for cells that contain markers and copying that range to a new
worksheet. I'm retaining the value of the cells and also would like to format
the cells with the ">" marker as bold and LeftJustified.
Your suggestions would be greatly appreciated.

Dave

Sheets("Items").Activate
ktr = 8
Set percrange = Range(Cells(1, 1), Cells(150, 1))
For Each thing In percrange
If IsNumeric(thing) And (thing > 0) Or (thing = ">") Or (thing =
">>") Then
ktr = ktr + 1
currrow = thing.Row
Range(Cells(currrow, 1), Cells(currrow, 9)).Select
Range(Cells(currrow, 1), Cells(currrow, 9)).Copy
Sheets("Sheet").Activate
Range(Cells(ktr, 1), Cells(ktr, 9)).PasteSpecial (xlPasteValues)
Sheets("Items").Activate
End If
Next

 
Reply With Quote
 
 
 
 
Don Guillett
Guest
Posts: n/a
 
      16th Feb 2009
This could be a lot more efficient. Show us your layout or send your wb to
my address below with before/after examples.

--
Don Guillett
Microsoft MVP Excel
SalesAid Software
(E-Mail Removed)
"DaveH" <(E-Mail Removed)> wrote in message
news:C439EC79-8766-4BF2-8B1A-(E-Mail Removed)...
>I seem to be having brain lock and cannot figure out how to add additional
> formatting to my code.
> Code below.
> I'm looking for cells that contain markers and copying that range to a new
> worksheet. I'm retaining the value of the cells and also would like to
> format
> the cells with the ">" marker as bold and LeftJustified.
> Your suggestions would be greatly appreciated.
>
> Dave
>
> Sheets("Items").Activate
> ktr = 8
> Set percrange = Range(Cells(1, 1), Cells(150, 1))
> For Each thing In percrange
> If IsNumeric(thing) And (thing > 0) Or (thing = ">") Or (thing =
> ">>") Then
> ktr = ktr + 1
> currrow = thing.Row
> Range(Cells(currrow, 1), Cells(currrow, 9)).Select
> Range(Cells(currrow, 1), Cells(currrow, 9)).Copy
> Sheets("Sheet").Activate
> Range(Cells(ktr, 1), Cells(ktr, 9)).PasteSpecial
> (xlPasteValues)
> Sheets("Items").Activate
> End If
> Next
>


 
Reply With Quote
 
DaveH
Guest
Posts: n/a
 
      16th Feb 2009
I'll send you my wb.

"Don Guillett" wrote:

> This could be a lot more efficient. Show us your layout or send your wb to
> my address below with before/after examples.
>
> --
> Don Guillett
> Microsoft MVP Excel
> SalesAid Software
> (E-Mail Removed)
> "DaveH" <(E-Mail Removed)> wrote in message
> news:C439EC79-8766-4BF2-8B1A-(E-Mail Removed)...
> >I seem to be having brain lock and cannot figure out how to add additional
> > formatting to my code.
> > Code below.
> > I'm looking for cells that contain markers and copying that range to a new
> > worksheet. I'm retaining the value of the cells and also would like to
> > format
> > the cells with the ">" marker as bold and LeftJustified.
> > Your suggestions would be greatly appreciated.
> >
> > Dave
> >
> > Sheets("Items").Activate
> > ktr = 8
> > Set percrange = Range(Cells(1, 1), Cells(150, 1))
> > For Each thing In percrange
> > If IsNumeric(thing) And (thing > 0) Or (thing = ">") Or (thing =
> > ">>") Then
> > ktr = ktr + 1
> > currrow = thing.Row
> > Range(Cells(currrow, 1), Cells(currrow, 9)).Select
> > Range(Cells(currrow, 1), Cells(currrow, 9)).Copy
> > Sheets("Sheet").Activate
> > Range(Cells(ktr, 1), Cells(ktr, 9)).PasteSpecial
> > (xlPasteValues)
> > Sheets("Items").Activate
> > End If
> > Next
> >

>
>

 
Reply With Quote
 
Don Guillett
Guest
Posts: n/a
 
      17th Feb 2009
Sub OrderSheetSAS()
Dim lr, br, dlr As Long
Dim c, firstaddress, i
Sheets("Order Sheet").Rows("7:100").Delete
With Worksheets("Fortis Items")
lr = .Cells(Rows.Count, "a").End(xlUp).Row
On Error Resume Next
For Each c In .Range("a2:a" & lr)
If InStr(c, ">") Or c > 0 Then
dlr = Sheets("Order Sheet").Cells(Rows.Count, 1).End(xlUp).Row + 1
Sheets("Order Sheet").Range("c1:c4").Value = _
Sheets("System Configurator").Range("c3:e6").Value
Sheets("Order Sheet").Rows(dlr).Value = .Rows(c.Row).Value
End If
Next c
End With
CleanUpSAS
End Sub

Sub CleanUpSAS()
Dim lr As Long
Dim c
With Sheets("Order Sheet")
lr = .Cells(Rows.Count, 1).End(xlUp).Row
For Each c In .Range("a7:a" & lr)
If InStr(c, ">") Then
..Rows(c.Row).Font.Bold = True
c.ClearContents
End If
Next c
End With
End Sub

--
Don Guillett
Microsoft MVP Excel
SalesAid Software
(E-Mail Removed)
"DaveH" <(E-Mail Removed)> wrote in message
news:718D7C63-7F3A-49CA-92C2-(E-Mail Removed)...
> I'll send you my wb.
>
> "Don Guillett" wrote:
>
>> This could be a lot more efficient. Show us your layout or send your wb
>> to
>> my address below with before/after examples.
>>
>> --
>> Don Guillett
>> Microsoft MVP Excel
>> SalesAid Software
>> (E-Mail Removed)
>> "DaveH" <(E-Mail Removed)> wrote in message
>> news:C439EC79-8766-4BF2-8B1A-(E-Mail Removed)...
>> >I seem to be having brain lock and cannot figure out how to add
>> >additional
>> > formatting to my code.
>> > Code below.
>> > I'm looking for cells that contain markers and copying that range to a
>> > new
>> > worksheet. I'm retaining the value of the cells and also would like to
>> > format
>> > the cells with the ">" marker as bold and LeftJustified.
>> > Your suggestions would be greatly appreciated.
>> >
>> > Dave
>> >
>> > Sheets("Items").Activate
>> > ktr = 8
>> > Set percrange = Range(Cells(1, 1), Cells(150, 1))
>> > For Each thing In percrange
>> > If IsNumeric(thing) And (thing > 0) Or (thing = ">") Or (thing =
>> > ">>") Then
>> > ktr = ktr + 1
>> > currrow = thing.Row
>> > Range(Cells(currrow, 1), Cells(currrow, 9)).Select
>> > Range(Cells(currrow, 1), Cells(currrow, 9)).Copy
>> > Sheets("Sheet").Activate
>> > Range(Cells(ktr, 1), Cells(ktr, 9)).PasteSpecial
>> > (xlPasteValues)
>> > Sheets("Items").Activate
>> > End If
>> > Next
>> >

>>
>>


 
Reply With Quote
 
DaveH
Guest
Posts: n/a
 
      18th Feb 2009
Don,
Works like a charm!
Many many thanks!

"Don Guillett" wrote:

> Sub OrderSheetSAS()
> Dim lr, br, dlr As Long
> Dim c, firstaddress, i
> Sheets("Order Sheet").Rows("7:100").Delete
> With Worksheets("Fortis Items")
> lr = .Cells(Rows.Count, "a").End(xlUp).Row
> On Error Resume Next
> For Each c In .Range("a2:a" & lr)
> If InStr(c, ">") Or c > 0 Then
> dlr = Sheets("Order Sheet").Cells(Rows.Count, 1).End(xlUp).Row + 1
> Sheets("Order Sheet").Range("c1:c4").Value = _
> Sheets("System Configurator").Range("c3:e6").Value
> Sheets("Order Sheet").Rows(dlr).Value = .Rows(c.Row).Value
> End If
> Next c
> End With
> CleanUpSAS
> End Sub
>
> Sub CleanUpSAS()
> Dim lr As Long
> Dim c
> With Sheets("Order Sheet")
> lr = .Cells(Rows.Count, 1).End(xlUp).Row
> For Each c In .Range("a7:a" & lr)
> If InStr(c, ">") Then
> ..Rows(c.Row).Font.Bold = True
> c.ClearContents
> End If
> Next c
> End With
> End Sub
>
> --
> Don Guillett
> Microsoft MVP Excel
> SalesAid Software
> (E-Mail Removed)
> "DaveH" <(E-Mail Removed)> wrote in message
> news:718D7C63-7F3A-49CA-92C2-(E-Mail Removed)...
> > I'll send you my wb.
> >
> > "Don Guillett" wrote:
> >
> >> This could be a lot more efficient. Show us your layout or send your wb
> >> to
> >> my address below with before/after examples.
> >>
> >> --
> >> Don Guillett
> >> Microsoft MVP Excel
> >> SalesAid Software
> >> (E-Mail Removed)
> >> "DaveH" <(E-Mail Removed)> wrote in message
> >> news:C439EC79-8766-4BF2-8B1A-(E-Mail Removed)...
> >> >I seem to be having brain lock and cannot figure out how to add
> >> >additional
> >> > formatting to my code.
> >> > Code below.
> >> > I'm looking for cells that contain markers and copying that range to a
> >> > new
> >> > worksheet. I'm retaining the value of the cells and also would like to
> >> > format
> >> > the cells with the ">" marker as bold and LeftJustified.
> >> > Your suggestions would be greatly appreciated.
> >> >
> >> > Dave
> >> >
> >> > Sheets("Items").Activate
> >> > ktr = 8
> >> > Set percrange = Range(Cells(1, 1), Cells(150, 1))
> >> > For Each thing In percrange
> >> > If IsNumeric(thing) And (thing > 0) Or (thing = ">") Or (thing =
> >> > ">>") Then
> >> > ktr = ktr + 1
> >> > currrow = thing.Row
> >> > Range(Cells(currrow, 1), Cells(currrow, 9)).Select
> >> > Range(Cells(currrow, 1), Cells(currrow, 9)).Copy
> >> > Sheets("Sheet").Activate
> >> > Range(Cells(ktr, 1), Cells(ktr, 9)).PasteSpecial
> >> > (xlPasteValues)
> >> > Sheets("Items").Activate
> >> > End If
> >> > Next
> >> >
> >>
> >>

>
>

 
Reply With Quote
 
 
 
Reply

Thread Tools
Rate This Thread
Rate This Thread:

Posting Rules
You may not post new threads
You may not post replies
You may not post attachments
You may not edit your posts

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


Similar Threads
Thread Thread Starter Forum Replies Last Post
Creating excel file, adding code to it from code, VBE window stays BlueWolverine Microsoft Excel Programming 0 5th Nov 2009 07:55 PM
code for formatting like custom cell formatting in excel DawnTreader Microsoft Access Form Coding 12 12th Jul 2008 01:12 PM
code for adding media player using c# code ram achar Microsoft C# .NET 0 14th Feb 2007 08:58 PM
Shorten code to apply to all sheets except a few, instead of individually naming them, and later adding to code. Corey Microsoft Excel Programming 3 11th Dec 2006 05:14 AM
Adding formatting to VBA code JRD Microsoft Excel Misc 4 11th Aug 2004 01:06 PM


Features
 

Advertising
 

Newsgroups
 


All times are GMT +1. The time now is 01:24 AM.