Jump to content
  • Welcome!

    Register and log in easily with Twitter or Google accounts!

    Or simply create a new Huddle account. 

    Members receive fewer ads , access our dark theme, and the ability to join the discussion!

     

Any Excel gurus here? Need help with a work problem and VBA.


C47

Recommended Posts

 I work with a lot of alphanumeric and numeric characters that look something like this...
00D184500
002A08800
00209100
00209200
0B3651300
07127400
07131000
0AF8230100
08310400
08310500
0H8310600
08701300
08741400
0T8741600
08741800
 
Up until now, they've only had leading zeros I need to remove, but now we're getting some with both leading and trailing zeros. What I need is a formula (preferably a VBA macro I can easily just shortcut to) to remove both the leading and trailing zeros from strings of data like this. These values would be formatted as text in the data sheets I'm working with. I was able to modify a formula I found online (see below) to remove leading zeros, so I really only need the trailing ones. Would it be possible to edit this into my working macro, or do I need to create a new macro for trailing?
 
Here's the macro I'm using to remove the leading zeros and it's working flawlessly...
 
Option Explicit
Sub removezeros()
 
Dim myCell As Range
Dim myRng As Range
Dim iCtr As Long
 
With Worksheets("Sheet1")
Set myRng = .Range("a1", .Cells(.Rows.Count, "A").End(xlUp))
For Each myCell In myRng.Cells
For iCtr = 1 To Len(myCell.Value)
If Mid(myCell.Value, iCtr, 1) <> "0" Then
Exit For
End If
Next iCtr
myCell.Value = Mid(myCell.Value, iCtr)
Next myCell
End With
 
End Sub
 
Anybody have any experience with VBA and can help me out here?
Link to comment
Share on other sites

Archived

This topic is now archived and is closed to further replies.


  • PMH4OWPW7JD2TDGWZKTOYL2T3E.jpg

  • Topics

  • Posts

    • Didn't know where to post this but it is panthers relevant since eventually we'll have a couple wr in Coker and tmac that will get paid. Jaxon Smith-njigba just signed a 4 year $168.6 million contract extension that now makes him the highest paid wr in nfl history. For now
    • Would be happy with Lomu or Iheanachor at 19. Fano is intriguing but I don't think he makes it.
    • II see it this way: We have to look at long-term needs and current depth.  We have filled some key spots with players on one-year contracts.  I firmly believe that they intend to pay Bryce some big bucks next year.  That means you cannot hope that your rookies in 2027 can fill the spots vacated by the veterans you could not afford to re-sign.   We need to consider the cap and the fact that the need to start a rookie is not viewed as a positive by coaches and general managers, but they value first contracts--so it is a delicate balance. I think they have to look at the cap by position--"Can we afford a $50m QB and a $100m OL?  That is half the cap, before you pay your WRs and RBs and TEs.  They need to start getting younger on the OL as well.   I am not suggesting that we draft OT in round 1, but we could and I would get it.  RT on a 1-year deal, they may have intel about Ickey (who was not the best LT, to be honest) and 32-year old Moton is on a bad wheel.   Now if you go by Morgan's history, you can almost tell what position we are going to address with the first pick by noting the positions he has not focused on in free agency.  DT, considering the lack of performance by those not named Derrick Brown and the loss of Robinson, is screaming to be addressed with a top player.  Wharton is not an early down DT (DE if you want to get technical) and our LBs need to be clean--they were not in 2025.  Look for a DT early. I also think we will address ILB (pass covering Will) on day 2.  The other day 2 pick will be an OT, in my view. Do not rule out CB.  We are thin there too, and Jackson is in his final year.  I am not sure that we love Smith-Wade.  Some crackhead on here talked about moving him to S----stay tuned.   Hopefully, a team wanting Ty Simpson will move up and offer us a pick or two to move back. DT WILB OT OC QB  (you heard it here 337th--but this pick could come sooner than you think.      
×
×
  • Create New...