Variable in " " in excel

Kingnight

New Member
Joined
Feb 5, 2011
Messages
38
Hey,

this is what I am trying to do

For Index = LBound(k) To UBound(k)

b.Cells(a, 1) = Application.WorksheetFunction.Substitute(b.Cells(a, 1), "k(Index)", "")

Next Index

but the variable K(index) does not work in this formula because of " ". (only show test " k(index) ". How it could still work in this situation? I really appreciate it.
:confused::confused::confused:

Thanks.
 

Excel Facts

Remove leading & trailing spaces
Save as CSV to remove all leading and trailing spaces. It is faster than using TRIM().
What are you trying to accomplish exactly and why the worksheet function?

I also wouldn't use INDEX as a variable as it is a VBA keyword.
 
Upvote 0
HOTPEPPER, you again. :)

I am trying to remove several strings in one string:

ex: Relating to the Nov 12, 2008 payment date
related to the Sep 5, 2009 distribution date
...
I only want dates: Nov 12, 2008 or Sep 5, 2009.

I am creating above formula (like filter) to remove "relating to the", "payment date", "related to the", "distribution date".

Hope it is clear.
 
Upvote 0
HOTPEPPER, you again. :)

I am trying to remove several strings in one string:

ex: Relating to the Nov 12, 2008 payment date
related to the Sep 5, 2009 distribution date
...
I only want dates: Nov 12, 2008 or Sep 5, 2009.

Assuming you only want to retrieve one date per string value, would this UDF (user defined function) be of any help to you (it retrieves the date directly)?

Code:
Function GetDate(StringIn As String) As Date
  Dim X As Long, MaybeDate As Variant, Parts() As String
  Parts = Split(StringIn)
  For X = 0 To UBound(Parts) - 4
    MaybeDate = Parts(X) & " " & Parts(X + 1) & " " & Parts(X + 2)
    If IsDate(MaybeDate) Then
      GetDate = CDate(MaybeDate)
      Exit Function
    End If
  Next
  GetDate = CVErr(xlErrValue)
End Function
 
Upvote 0

Forum statistics

Threads
1,224,527
Messages
6,179,331
Members
452,907
Latest member
Roland Deschain

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