PC Review


Reply
Thread Tools Rate Thread

adjust cell width change font.

 
 
Peter
Guest
Posts: n/a
 
      5th Apr 2010
Hello

I'm doing a copy and paste of cell values, my question is, when I paste the
values into the cells, how do I get them to be all the same font, and some
of the cells are text string, so how do I have te cells adjust for width?

Currently I've got
For Each x In Range("c1:c100")
If Not IsEmpty(x) Then


With SrcRange
Set rngFind = .Find(z)


If Not rngFind Is Nothing Then

x.Offset(0, 7) = rngFind.Offset(0, 1).Value
x.Offset(0, 8).Value = rngFind.Offset(0, 3).Value
x.Offset(0, 9).Value = rngFind.Offset(0, 6).Value
x.Offset(0, 10).Value = rngFind.Offset(0, 7).Value
x.Offset(0, 11).Value = rngFind.Offset(0, 8).Value
x.Offset(0, 12).Value = rngFind.Offset(0, 2).Value
x.Offset(0, 13).Value = rngFind.Offset(0, 4).Value
End If
End With

End If
Next x

and that gives me

Note different font size... then the first cell needs t obe adjusted for the
correct width.

5 Bay Base Station B 4/3/2009 220700 1/1/1900 12005
Some example Test B 1/28/2008 31100 11000 1/1/1900 10729
More Example text shown here A 1/27/2009 69374 2567 1/1/1900 11713


 
Reply With Quote
 
 
 
 
JLGWhiz
Guest
Posts: n/a
 
      6th Apr 2010
Between your End If and End With you could add:

Columns(x.Offset(0, 7).Column).Autofit
Range(x.Offset(0, 8).Address, _
x.Offset(0, 13).Address).Font.Size = 12 '<<or whatever size



"Peter" <(E-Mail Removed)> wrote in message
news:(E-Mail Removed)...
> Hello
>
> I'm doing a copy and paste of cell values, my question is, when I paste
> the values into the cells, how do I get them to be all the same font, and
> some of the cells are text string, so how do I have te cells adjust for
> width?
>
> Currently I've got
> For Each x In Range("c1:c100")
> If Not IsEmpty(x) Then
>
>
> With SrcRange
> Set rngFind = .Find(z)
>
>
> If Not rngFind Is Nothing Then
>
> x.Offset(0, 7) = rngFind.Offset(0, 1).Value
> x.Offset(0, 8).Value = rngFind.Offset(0, 3).Value
> x.Offset(0, 9).Value = rngFind.Offset(0, 6).Value
> x.Offset(0, 10).Value = rngFind.Offset(0, 7).Value
> x.Offset(0, 11).Value = rngFind.Offset(0, 8).Value
> x.Offset(0, 12).Value = rngFind.Offset(0, 2).Value
> x.Offset(0, 13).Value = rngFind.Offset(0, 4).Value
> End If
> End With
>
> End If
> Next x
>
> and that gives me
>
> Note different font size... then the first cell needs t obe adjusted for
> the correct width.
>
> 5 Bay Base Station B 4/3/2009 220700 1/1/1900 12005
> Some example Test B 1/28/2008 31100 11000 1/1/1900 10729
> More Example text shown here A 1/27/2009 69374 2567 1/1/1900 11713
>
>



 
Reply With Quote
 
FSt1
Guest
Posts: n/a
 
      6th Apr 2010
hi
small techicallity. you're not coping and pasting. you are just having one
range value equal another range value. copy and paste uses the windows
clipboard. in this case we are not using the clipboard.

you need to add code to adjust the width and set the fonts. i would use the
resize method and do it as the end of each loop. this should work....
x.Offset(0, 7).Value = rngFind.Offset(0, 1).Value
x.Offset(0, 8).Value = rngFind.Offset(0, 3).Value
x.Offset(0, 9).Value = rngFind.Offset(0, 6).Value
x.Offset(0, 10).Value = rngFind.Offset(0, 7).Value
x.Offset(0, 11).Value = rngFind.Offset(0, 8).Value
x.Offset(0, 12).Value = rngFind.Offset(0, 2).Value
x.Offset(0, 13).Value = rngFind.Offset(0, 4).Value

x.Offset(0, 7).Resize(1, 7).Columns.AutoFit ' adjust if needed
x.EntireRow.AutoFit
x.Offset(0, 7).Resize(1, 7).Font.Name = "Arial"
x.Offset(0, 7).Resize(1, 7).Font.Size = 10

regards
FSt1

"Peter" wrote:

> Hello
>
> I'm doing a copy and paste of cell values, my question is, when I paste the
> values into the cells, how do I get them to be all the same font, and some
> of the cells are text string, so how do I have te cells adjust for width?
>
> Currently I've got
> For Each x In Range("c1:c100")
> If Not IsEmpty(x) Then
>
>
> With SrcRange
> Set rngFind = .Find(z)
>
>
> If Not rngFind Is Nothing Then
>
> x.Offset(0, 7) = rngFind.Offset(0, 1).Value
> x.Offset(0, 8).Value = rngFind.Offset(0, 3).Value
> x.Offset(0, 9).Value = rngFind.Offset(0, 6).Value
> x.Offset(0, 10).Value = rngFind.Offset(0, 7).Value
> x.Offset(0, 11).Value = rngFind.Offset(0, 8).Value
> x.Offset(0, 12).Value = rngFind.Offset(0, 2).Value
> x.Offset(0, 13).Value = rngFind.Offset(0, 4).Value
> End If
> End With
>
> End If
> Next x
>
> and that gives me
>
> Note different font size... then the first cell needs t obe adjusted for the
> correct width.
>
> 5 Bay Base Station B 4/3/2009 220700 1/1/1900 12005
> Some example Test B 1/28/2008 31100 11000 1/1/1900 10729
> More Example text shown here A 1/27/2009 69374 2567 1/1/1900 11713
>
>
> .
>

 
Reply With Quote
 
FSt1
Guest
Posts: n/a
 
      6th Apr 2010
hi
just notice something.
i would move the row.autofit to after the font.size .......just in case.

regards
FSt1

"FSt1" wrote:

> hi
> small techicallity. you're not coping and pasting. you are just having one
> range value equal another range value. copy and paste uses the windows
> clipboard. in this case we are not using the clipboard.
>
> you need to add code to adjust the width and set the fonts. i would use the
> resize method and do it as the end of each loop. this should work....
> x.Offset(0, 7).Value = rngFind.Offset(0, 1).Value
> x.Offset(0, 8).Value = rngFind.Offset(0, 3).Value
> x.Offset(0, 9).Value = rngFind.Offset(0, 6).Value
> x.Offset(0, 10).Value = rngFind.Offset(0, 7).Value
> x.Offset(0, 11).Value = rngFind.Offset(0, 8).Value
> x.Offset(0, 12).Value = rngFind.Offset(0, 2).Value
> x.Offset(0, 13).Value = rngFind.Offset(0, 4).Value
>
> x.Offset(0, 7).Resize(1, 7).Columns.AutoFit ' adjust if needed
> x.EntireRow.AutoFit
> x.Offset(0, 7).Resize(1, 7).Font.Name = "Arial"
> x.Offset(0, 7).Resize(1, 7).Font.Size = 10
>
> regards
> FSt1
>
> "Peter" wrote:
>
> > Hello
> >
> > I'm doing a copy and paste of cell values, my question is, when I paste the
> > values into the cells, how do I get them to be all the same font, and some
> > of the cells are text string, so how do I have te cells adjust for width?
> >
> > Currently I've got
> > For Each x In Range("c1:c100")
> > If Not IsEmpty(x) Then
> >
> >
> > With SrcRange
> > Set rngFind = .Find(z)
> >
> >
> > If Not rngFind Is Nothing Then
> >
> > x.Offset(0, 7) = rngFind.Offset(0, 1).Value
> > x.Offset(0, 8).Value = rngFind.Offset(0, 3).Value
> > x.Offset(0, 9).Value = rngFind.Offset(0, 6).Value
> > x.Offset(0, 10).Value = rngFind.Offset(0, 7).Value
> > x.Offset(0, 11).Value = rngFind.Offset(0, 8).Value
> > x.Offset(0, 12).Value = rngFind.Offset(0, 2).Value
> > x.Offset(0, 13).Value = rngFind.Offset(0, 4).Value
> > End If
> > End With
> >
> > End If
> > Next x
> >
> > and that gives me
> >
> > Note different font size... then the first cell needs t obe adjusted for the
> > correct width.
> >
> > 5 Bay Base Station B 4/3/2009 220700 1/1/1900 12005
> > Some example Test B 1/28/2008 31100 11000 1/1/1900 10729
> > More Example text shown here A 1/27/2009 69374 2567 1/1/1900 11713
> >
> >
> > .
> >

 
Reply With Quote
 
Peter
Guest
Posts: n/a
 
      6th Apr 2010
Thanks for the help, that works
"Peter" <(E-Mail Removed)> wrote in message
news:(E-Mail Removed)...
> Hello
>
> I'm doing a copy and paste of cell values, my question is, when I paste
> the values into the cells, how do I get them to be all the same font, and
> some of the cells are text string, so how do I have te cells adjust for
> width?
>
> Currently I've got
> For Each x In Range("c1:c100")
> If Not IsEmpty(x) Then
>
>
> With SrcRange
> Set rngFind = .Find(z)
>
>
> If Not rngFind Is Nothing Then
>
> x.Offset(0, 7) = rngFind.Offset(0, 1).Value
> x.Offset(0, 8).Value = rngFind.Offset(0, 3).Value
> x.Offset(0, 9).Value = rngFind.Offset(0, 6).Value
> x.Offset(0, 10).Value = rngFind.Offset(0, 7).Value
> x.Offset(0, 11).Value = rngFind.Offset(0, 8).Value
> x.Offset(0, 12).Value = rngFind.Offset(0, 2).Value
> x.Offset(0, 13).Value = rngFind.Offset(0, 4).Value
> End If
> End With
>
> End If
> Next x
>
> and that gives me
>
> Note different font size... then the first cell needs t obe adjusted for
> the correct width.
>
> 5 Bay Base Station B 4/3/2009 220700 1/1/1900 12005
> Some example Test B 1/28/2008 31100 11000 1/1/1900 10729
> More Example text shown here A 1/27/2009 69374 2567 1/1/1900 11713
>
>



 
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
Cell width auto adjust KB Microsoft Excel Misc 0 26th Dec 2008 08:21 PM
adjust width of single cell in Excel =?Utf-8?B?b3JhdnNreTEyMw==?= Microsoft Excel Charting 1 28th Aug 2007 05:49 PM
how to adjust the width of a cell and not the entire column =?Utf-8?B?Z2FicmllIHJ1eg==?= Microsoft Excel Misc 3 3rd Aug 2006 05:53 PM
Adjust Cell Width in Visual Basic =?Utf-8?B?ag==?= Microsoft Excel Misc 2 5th Jul 2006 07:48 PM
adjust height & width of cell in datagrid Shri Microsoft C# .NET 0 9th Aug 2004 06:55 PM


Features
 

Advertising
 

Newsgroups
 


All times are GMT +1. The time now is 04:29 AM.