#1   Report Post  
Posted to microsoft.public.excel.programming
external usenet poster
 
Posts: 7
Default offset

Hi, im using the following code to move all the text from all the columns on
a row to the first column. It works great except that i have also numbers
that include decimals like 33.56. When it is copied to the first column on a
row excel rounds it to 34. How can i stop this rounding from happening?
The data in a cell can be text or numbers like
c | 33.56 | %
and it should turn out like
c 33.56 %
but it turns out like
c 34 %

Sub MakeOneCol()
Dim ThisRow As Range
Dim NewVal As String
Dim i, j As Integer
Set ThisRow = Sheets("Summary").Cells(1, 1)
For i = 0 To 54
NewVal = ""
For j = 0 To 5
NewVal = NewVal & Format(ThisRow.Offset(i, j), 0) & " "
Next j
ThisRow.Offset(i, 0) = NewVal
Next i
Sheets("Summary").Range("B2", "F55").Delete (1)
Sheets("Summary").PageSetup.PrintArea = "$A$1:$F$55"
End Sub

Youll be a hero if you help me.


  #2   Report Post  
Posted to microsoft.public.excel.programming
external usenet poster
 
Posts: 27,285
Default offset

change
NewVal & Format(ThisRow.Offset(i, j), 0) & " "


to

NewVal & Format(ThisRow.Offset(i, j), 0.00) & " "

would be my guess. or don't use format

NewVal & ThisRow.Offset(i, j).Value & " "

or
NewVal & ThisRow.Offset(i, j).text & " "

if you want to duplicate what is displayed in the cell.

--
Regards,
Tom Ogilvy



"T.K Kullervo" wrote in message
...
Hi, im using the following code to move all the text from all the columns

on
a row to the first column. It works great except that i have also numbers
that include decimals like 33.56. When it is copied to the first column on

a
row excel rounds it to 34. How can i stop this rounding from happening?
The data in a cell can be text or numbers like
c | 33.56 | %
and it should turn out like
c 33.56 %
but it turns out like
c 34 %

Sub MakeOneCol()
Dim ThisRow As Range
Dim NewVal As String
Dim i, j As Integer
Set ThisRow = Sheets("Summary").Cells(1, 1)
For i = 0 To 54
NewVal = ""
For j = 0 To 5
NewVal = NewVal & Format(ThisRow.Offset(i, j), 0) & " "
Next j
ThisRow.Offset(i, 0) = NewVal
Next i
Sheets("Summary").Range("B2", "F55").Delete (1)
Sheets("Summary").PageSetup.PrintArea = "$A$1:$F$55"
End Sub

Youll be a hero if you help me.




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
Do I really need OFFSET? bflorox Charts and Charting in Excel 3 October 21st 08 09:02 PM
Compare Cell Values, Offset(-1,0), Offset(-1,-1), and xlFillDefaul RyGuy Excel Worksheet Functions 2 September 28th 07 10:54 PM
Offset Help Hunter Excel Worksheet Functions 5 January 26th 07 02:21 PM
Offset. Joe Edwards Excel Worksheet Functions 2 November 2nd 06 06:57 AM
OFFSET PLEASE HELP! HERNAN Excel Discussion (Misc queries) 6 October 27th 06 10:17 PM


All times are GMT +1. The time now is 02:12 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"