Avatar of RWayneH
RWayneH
Flag for United States of America asked on

Why would blank a cell.

I am using a line in VBA:

ActiveCell = strVBELN

Why when it hits this line would it empty the cell?  and now strVBELN is = ""
Microsoft Excel

Avatar of undefined
Last Comment
Martin Liss

8/22/2022 - Mon
Martin Liss

If strVBELN is blank the cell will become blank.
ASKER CERTIFIED SOLUTION
Martin Liss

Log in or sign up to see answer
Become an EE member today7-DAY FREE TRIAL
Members can start a 7-Day Free trial then enjoy unlimited access to the platform
Sign up - Free for 7 days
or
Learn why we charge membership fees
We get it - no one likes a content blocker. Take one extra minute and find out why we block content.
Not exactly the question you had in mind?
Sign up for an EE membership and get your own personalized solution. With an EE membership, you can ask unlimited troubleshooting, research, or opinion questions.
ask a question
RWayneH

ASKER
So how do I make the ActiveCell = strVBELN, without removing it?
Martin Liss

I don't understand. When you say "without removing it", what is the "it" you are referring to?
This is the best money I have ever spent. I cannot not tell you how many times these folks have saved my bacon. I learn so much from the contributors.
rwheeler23
RWayneH

ASKER
It skips over your Ln2 were I am trying to make it = strVBELN
RWayneH

ASKER
it is the ActiveCell....  it blanks it out after trying to assign what is there to strVBELN
Martin Liss

Maybe you can describe the situation. Does the activecell already have something in it? Do you want to replace what's in it or do you want to append strVBELN to it?
Get an unlimited membership to EE for less than $4 a week.
Unlimited question asking, solutions, articles and more.
Anthony Berenguel

RWayneH, it sounds like you need to use Martin Liss' suggested code that checks to see if strBLEVN is empty. If it's empty then it won't do anything to the active cell. However, if it's not empty then it will assign its value to the active cell.
Martin Liss

It skips over your Ln2 were I am trying to make it = strVBELN
Well then strVBELN must be blank.
RWayneH

ASKER
Here is what I am doing.  It is not assigning the value that is in A2...   strVBELN    (I see a typo in your reply BL?  )
It is skipping over Ln15

Sub GoThruListOfSalesOrders()
sessChoice = "QEC"  'variables used by TESTSAP function
connChoice = "900"
If TestSAP = False Then Exit Sub

Sheets("ListPg").Select
Range("A2").Select
If ActiveCell = "" Then
    MsgBox ("Either list is done, or list was blank.  List of SalesOrder should beginning in cell A2")
    GoTo 200
End If

Do While Not ActiveCell = ""
    If Trim(strVBELN) <> "" Then
    ActiveCell = strVBELN
    End If
   
    session.findById("wnd[0]/tbar[0]/okcd").Text = "/nVA03" 'enter tcode in shortcut field
    session.findById("wnd[0]").sendVKey 0  'press enter
    session.findById("wnd[0]/usr/ctxtVBAK-VBELN").Text = strVBELN
    session.findById("wnd[0]").sendVKey 0  'press enter
    Call GetDataFromSOLN
Loop
200
End Sub

Open in new window

Experts Exchange has (a) saved my job multiple times, (b) saved me hours, days, and even weeks of work, and often (c) makes me look like a superhero! This place is MAGIC!
Walt Forbes
Martin Liss

Is strVBELN the name of a cell?
RWayneH

ASKER
got it.  It was backwards

strVBELN = ActiveCell     worked.
RWayneH

ASKER
Just needed to flip-flop the Ln..   Thanks for the help
Get an unlimited membership to EE for less than $4 a week.
Unlimited question asking, solutions, articles and more.
Martin Liss

You're welcome and I'm glad I was able to help.

In my profile you'll find links to some articles I've written that may interest you.
Marty - MVP 2009 to 2014