• python
  • javascript
  • reactjs
  • sql
  • c#
  • java
Facebook Twitter Instagram
Devs Fixed
  • python
  • javascript
  • reactjs
  • sql
  • c#
  • java
Devs Fixed
Home » Resolved: How can I add 0’s to a string based on string length difference compared to target length?

Resolved: How can I add 0’s to a string based on string length difference compared to target length?

0
By Isaac Tonny on 17/06/2022 Issue
Share
Facebook Twitter LinkedIn

Question:

I need to make sure all cells in each column have that column’s target length. When the target length is larger than the actual length of the string value in the given cell, x amount of 0s must be added in front in order to make the string’s length be equal to the target.
So far I have this code:
last_row_index is a simple UDF using the End.xlUp method to find last continuous row index. The loop works well, giving me the difference in Integer format.
Taking that integer and turning it into 0s that go in front of the cell.value is the issue I am having trouble solving. I have seen solutions to similar problems for Python, but I am very new to coding and I am having trouble understanding the process.

Answer:

in the cell like this, e.g. for 10 digits of length:

If you have better answer, please add a comment about this, thank you!

excel loops string vba
Share. Facebook Twitter LinkedIn

Related Posts

Resolved: In a Pinescript v5 Strategy why is my bool not working?

02/04/2023

Resolved: net::ERR_HTTP2_PROTOCOL_ERROR by http get request angular 15.2

02/04/2023

Resolved: How do I stop the command from happening if the requirements for it to work aren’t sert Discord.js

02/04/2023

Leave A Reply

© 2023 DEVSFIX.COM

Type above and press Enter to search. Press Esc to cancel.