你怎样从一个数组中的时间(以“HH:MM”格式)中移除冒号?

huangapple go评论49阅读模式
英文:

How do you remove the colon from a time in the "HH:MM" format when the time is placed in the range from an array?

问题

Sheet 1:

8:00 AM
9:00 AM
12:00 AM
2:00 PM
2:43 PM

Sheet 2:

800
900
1200
200
243
英文:

I have a database of times formatted as "8:00 AM", "12:00 PM", etc. I need to transfer those times to a different sheet in a different format.

Ex:
Sheet 1:

8:00 AM
9:00 AM
12:00 AM
2:00 Pm
2:43 PM

Sheet 2:

800
900
1200
200
243

I tried to just use the left and right functions, but it would read it as a decimal.

'For single digit hours
NewTime(i) = Left(NewTime(i),1) & Right(NewTime(i),2)

答案1

得分: 2

你将一个新的.NumberFormat 应用于该范围,例如:

Sheet2.Range("A1:A5").NumberFormat = "hmm"
英文:

You apply a new .NumberFormat to the range, e.g.

Sheet2.Range("A1:A5").NumberFormat = "hmm"

huangapple
  • 本文由 发表于 2023年7月18日 01:11:10
  • 转载请务必保留本文链接:https://go.coder-hub.com/76706705.html
匿名

发表评论

匿名网友

:?: :razz: :sad: :evil: :!: :smile: :oops: :grin: :eek: :shock: :???: :cool: :lol: :mad: :twisted: :roll: :wink: :idea: :arrow: :neutral: :cry: :mrgreen:

确定