Vba for formatting cell

Alpacino

Well-known Member
Joined
Mar 16, 2011
Messages
511
Hi again
I would like a vba to convert values from a range Z4:Z35 then copy to C4:C35
Say the value in Z4 is 34 I like to multiple the value by 1000 then copy new format to C4.

At the moment I have to do a sum formula into Y4 =SUM(Z4*1000) then copy values to C4. I just want to bypass this painful way of doing it

Thanks for ur help
Alan
 

Excel Facts

Create a chart in one keystroke
Select the data and press Alt+F1 to insert a default chart. You can change the default chart to any chart type
You could just put "=Z4*1000" into C4 or you could use something like
Code:
Sub ZtoC()
    With Range("C4:C35")
        .Formula = "=Z4*1000"
        .Value = .Value
    End With
End Sub
 
Upvote 0
I forgot to mention I use a for next loop with a vlookup formula as follows:
"sales" is a range 2 columns with y being names same as column A and z column.

Sub vlookupSales

Dim I as long
For I = 4 to 35

Cells(I , 3).formulaR1C1 = application.worksheetfunction.vlookup(cells(I,1),range("sales"),2,0)
Next I
End sub

How do I add this to the sub above. I use this sub straight after I use tp format the z column.
 
Upvote 0
Your Vlookup seems to be done in C4:C35, the same place that the Col Z*1000 results now are.

Is that right?
 
Upvote 0
Yeah that's right what I do is format the values in z column to y then results from vlookup in column c
 
Upvote 0
Well the y column would be =sum(z4*1000)
A bit more detail z column has figures in 000's shortened
Eg z4 = 34 k I want to format this To 34000.
The source of z values is from another workbook and the names and values are in different order to my sheet. That's why I'm using vlookup to reorder the values to the right name in column c.
 
Upvote 0
If Z4 has the text constant "34 k" (without the quote marks) in it, then you can use this formula to return 34000...

=1000*LEFT(Z4,FIND(" ",Z4)-1)

Although if you plan to copy the formula down, possibly through blank cells in Column Z (in anticipation of more entries being made in the future), then you would probably want this version of the formula...

=IF(Z4="","",1000*LEFT(Z4,FIND(" ",Z4)-1))

However, I just wanted to point out to you in case you can make use of this, there is a way to have the cell value be 34000 while it displays as "34 k"; simply Custom Format the cell using this format pattern...

0," k"
 
Upvote 0

Forum statistics

Threads
1,224,599
Messages
6,179,828
Members
452,946
Latest member
JoseDavid

We've detected that you are using an adblocker.

We have a great community of people providing Excel help here, but the hosting costs are enormous. You can help keep this site running by allowing ads on MrExcel.com.
Allow Ads at MrExcel

Which adblocker are you using?

Disable AdBlock

Follow these easy steps to disable AdBlock

1)Click on the icon in the browser’s toolbar.
2)Click on the icon in the browser’s toolbar.
2)Click on the "Pause on this site" option.
Go back

Disable AdBlock Plus

Follow these easy steps to disable AdBlock Plus

1)Click on the icon in the browser’s toolbar.
2)Click on the toggle to disable it for "mrexcel.com".
Go back

Disable uBlock Origin

Follow these easy steps to disable uBlock Origin

1)Click on the icon in the browser’s toolbar.
2)Click on the "Power" button.
3)Click on the "Refresh" button.
Go back

Disable uBlock

Follow these easy steps to disable uBlock

1)Click on the icon in the browser’s toolbar.
2)Click on the "Power" button.
3)Click on the "Refresh" button.
Go back
Back
Top