Code not working- help

NeoSez

Board Regular
Joined
Aug 14, 2020
Messages
210
Office Version
  1. 2019
  2. 2010
Platform
  1. Windows
What is wrong with this code? It's not working.
I want to extract date only, from column T in this format 08/26/2020. The date usually appears at the beginning of a bunch of text.

VBA Code:
or kk = 1 To Len(fullstr)

        digt = Mid(A1, Find("/", A1, 1) - 2, 10)

        If IsNumeric(digt) And startstr < 0 Then ' check for the first number in the string

           startstr = kk   ' set this to start of the string

        End If

        digasc = Asc(digt)   ' convert the current character to ascii

        If startstr > 0 And (digasc > 57 Or digasc < 47) Then ' this checks whether the digit is a number or /

         endstr = kk ' set then end of the string as the first character which isn't a number or a slash

         Exit For

        End If

    Next kk

      If startstr > 0 Then

      dt = Mid(fullstr, startstr, endstr - startstr + 1)

      mastarr(i, 7) = dt
 
to get rid of the space after: change this line:
VBA Code:
dt = Mid(fullstr, startstr, endstr - startstr + 1)
to
VBA Code:
dt = Mid(fullstr, startstr, endstr - startstr)
 
Upvote 0

Excel Facts

Wildcard in VLOOKUP
Use =VLOOKUP("Apple*" to find apple, Apple, or applesauce

Forum statistics

Threads
1,214,960
Messages
6,122,479
Members
449,088
Latest member
Melvetica

We've detected that you are using an adblocker.

We have a great community of people providing Excel help here, but the hosting costs are enormous. You can help keep this site running by allowing ads on MrExcel.com.
Allow Ads at MrExcel

Which adblocker are you using?

Disable AdBlock

Follow these easy steps to disable AdBlock

1)Click on the icon in the browser’s toolbar.
2)Click on the icon in the browser’s toolbar.
2)Click on the "Pause on this site" option.
Go back

Disable AdBlock Plus

Follow these easy steps to disable AdBlock Plus

1)Click on the icon in the browser’s toolbar.
2)Click on the toggle to disable it for "mrexcel.com".
Go back

Disable uBlock Origin

Follow these easy steps to disable uBlock Origin

1)Click on the icon in the browser’s toolbar.
2)Click on the "Power" button.
3)Click on the "Refresh" button.
Go back

Disable uBlock

Follow these easy steps to disable uBlock

1)Click on the icon in the browser’s toolbar.
2)Click on the "Power" button.
3)Click on the "Refresh" button.
Go back
Back
Top