VBA InputBox Issue

Anonymous
2021-03-05T18:47:39+00:00

I have a simple macro. To copy values from one workbook to another in this case ML to MCR based on the user input number.

Number format can be e.g M5888-9087, M1990A 600111512, 453564034421 822349224.

Macro works with numbers like M5888-9087 but if I enter M1990A 600111512 or 453564034421 822349224 it copies all the rows instead of filtering M1990A 600111512 or 453564034421 822349224 and copying those selected rows.

Space in between is the culprit. How to overcome this?

Does changing the filter helps? I see other filters in object library.

Sub MCR()

Dim myInp As Variant

myInp = VBA.Interaction.InputBox(Prompt:="Enter the number", Title:="MCR Macro")

Windows("ML.xlsx").Activate

Worksheets("Full-View").Select

Worksheets("Full-View").ListObjects("Table1").Range.AutoFilter Field:=1, Criteria1:=myInp

Range("Table1[[#Headers],[Serial]]").Select

ActiveCell.Offset(1, 7).Range("Table1[[#Headers],[Serial]]").Select

Range(Selection, Selection.End(xlDown)).Select

Selection.Copy

Windows("MCR Macro.xlsm").Activate

Range("A4").PasteSpecial Paste:=xlPasteValues, Operation:=xlNone, SkipBlanks _

:=False, Transpose:=False

End Sub

Microsoft 365 and Office | Excel | For home | Windows

Locked Question. This question was migrated from the Microsoft Support Community. You can vote on whether it's helpful, but you can't add comments or replies or follow the question.

0 comments No comments

99 answers

Sort by: Most helpful
  1. OssieMac 48,006 Reputation points Volunteer Moderator
    2021-04-22T23:28:52+00:00

    Had a little bit of time this morning to look at this but the file transfer is expired so can't do anything.

    Was this answer helpful?

    0 comments No comments
  2. OssieMac 48,006 Reputation points Volunteer Moderator
    2021-04-21T22:32:18+00:00

    Unfortunately my wife has developed health problems and it is taking up so much of my time with both medical appointments and looking after her. I'll try to get back to it in the next week or so but I can't give you any promises.

    Was this answer helpful?

    0 comments No comments
  3. Anonymous
    2021-04-21T20:25:51+00:00

    I just wanted to check if you are back at it.

    Was this answer helpful?

    0 comments No comments
  4. Anonymous
    2021-04-14T21:38:31+00:00

    Take your time. Once everything is clear then give it a try.

    Was this answer helpful?

    0 comments No comments
  5. OssieMac 48,006 Reputation points Volunteer Moderator
    2021-04-14T20:23:33+00:00

    Got other things going on for the next couple of days so will have a look at it after that.

    Was this answer helpful?

    0 comments No comments