![]() |
vba format question
cells(1).value = 3
With code I would like to convert this value into 03 for use elsewhere ie:show single digit numbers as 2 digit in a message box I've tried variations of the code below but no joy so far dim txt as string txt = format(cells(1).value, "00") msgbox txt |
vba format question
This code seems to work for me with the sheet with A1 holding 3 in it
currently active: Dim myText As String myText = Format(ActiveSheet.Cells(1), "00") MsgBox myText "David" wrote: cells(1).value = 3 With code I would like to convert this value into 03 for use elsewhere ie:show single digit numbers as 2 digit in a message box I've tried variations of the code below but no joy so far dim txt as string txt = format(cells(1).value, "00") msgbox txt |
vba format question
Thanks J
This is a weird one Original code worked ok on my home machine Today works OK on the original machine When I first posted the problem I was getting a single chr "3" in msgbox Tried & failed to reproduce the problem today by reformatting cells(1) Maybe a bug? Thanks anyway "JLatham" wrote: This code seems to work for me with the sheet with A1 holding 3 in it currently active: Dim myText As String myText = Format(ActiveSheet.Cells(1), "00") MsgBox myText "David" wrote: cells(1).value = 3 With code I would like to convert this value into 03 for use elsewhere ie:show single digit numbers as 2 digit in a message box I've tried variations of the code below but no joy so far dim txt as string txt = format(cells(1).value, "00") msgbox txt |
All times are GMT +1. The time now is 10:26 AM. |
Powered by vBulletin® Copyright ©2000 - 2025, Jelsoft Enterprises Ltd.
ExcelBanter.com