Format issue in VB code (Macro)

rrajansg

New Member
Joined
Mar 17, 2011
Messages
12
I have code like this to prepare summary from another sheet.

For K = 2 To Sheets(I).Cells.SpecialCells(xlLastCell).Row
Range("A" + Format(J)).FormulaR1C1 = "='" + a$ + "'!R" + Format(K) + "C1"
Range("B" + Format(J)).FormulaR1C1 = "='" + a$ + "'!R" + Format(K) + "C2"
Range("C" + Format(J)).FormulaR1C1 = "='" + a$ + "'!R" + Format(K) + "C3"
Range("D" + Format(J)).FormulaR1C1 = "='" + a$ + "'!R" + Format(K) + "C4"
J = J + 1

It works well, except format issue. Wherever there is no data, it shows 0. I need blank instead of zero.

Can you please fix this issue

Thanks
 

Excel Facts

Why does 9 mean SUM in SUBTOTAL?
It is because Sum is the 9th alphabetically in Average, Count, CountA, Max, Min, Product, StDev.S, StDev.P, Sum, VAR.S, VAR.P.
Have you considered something like Replace("0", "", xlWhole) at the end of the code for the relevant range?
 
Upvote 0
Thanks for quick response

I am not very familiar with VB. The earlier vb code was given by one of member from this forum. i am trying to add in the end of every range. but it doesn't work
 
Upvote 0
Perhaps if you give an overall view of what you are trying to achieve, then some good answers may be forthcoming from the forum without necessarily trying to modify a code which doesn't seem to entirely work for you anyway.
 
Upvote 0

Forum statistics

Threads
1,224,599
Messages
6,179,827
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