vba - Text Function for multiple cells -


i wanted know if there alternative method (than loops) using text function on multiple cells.

for example, below code work correctly lookups

range("c2:c6").value = application.worksheetfunction.vlookup(range("a2:a6"), range("a2:b6"), 2, 0) 

however error below text functions

range("c2:c6").value = application.worksheetfunction.text(range("a2:a6"), "000000") 

surly want format cells , copy values?

like below?

    range("c2:c6")         .value = range("a2:a6").value         .numberformat = "000000"     end 

the macro recorder gave me similar above optimisations

using formula

range("c2").formular1c1 = "=text(rc[-2],""000000"")" range("c3").formular1c1 = "=text(rc[-2],""000000"")" range("c4").formular1c1 = "=text(rc[-2],""000000"")" range("c5").formular1c1 = "=text(rc[-2],""000000"")" range("c6").formular1c1 = "=text(rc[-2],""000000"")" 

or little bit more dynamic

for each cell in range("c2:c6")     cell.formular1c1 = "=text(rc[-2],""000000"")" next 

Comments

Popular posts from this blog

yii2 - Yii 2 Running a Cron in the basic template -

asp.net - 'System.Web.HttpContext' does not contain a definition for 'GetOwinContext' Mystery -

mercurial graft feature, can it copy? -