Sign Up

Sign Up to our social questions and Answers Engine to ask questions, answer people’s questions, and connect with other people.

Have an account? Sign In

Have an account? Sign In Now

Sign In

Login to our social questions & Answers Engine to ask questions answer people’s questions & connect with other people.

Sign Up Here

Forgot Password?

Don't have account, Sign Up Here

Forgot Password

Lost your password? Please enter your email address. You will receive a link and will create a new password via email.

Have an account? Sign In Now

You must login to ask a question.

Forgot Password?

Need An Account, Sign Up Here

Please briefly explain why you feel this question should be reported.

Please briefly explain why you feel this answer should be reported.

Please briefly explain why you feel this user should be reported.

Sign InSign Up

The Archive Base

The Archive Base Logo The Archive Base Logo

The Archive Base Navigation

  • SEARCH
  • Home
  • About Us
  • Blog
  • Contact Us
Search
Ask A Question

Mobile menu

Close
Ask a Question
  • Home
  • Add group
  • Groups page
  • Feed
  • User Profile
  • Communities
  • Questions
    • New Questions
    • Trending Questions
    • Must read Questions
    • Hot Questions
  • Polls
  • Tags
  • Badges
  • Buy Points
  • Users
  • Help
  • Buy Theme
  • SEARCH
Home/ Questions/Q 6644309
In Process

The Archive Base Latest Questions

Editorial Team
  • 0
Editorial Team
Asked: May 26, 20262026-05-26T00:09:09+00:00 2026-05-26T00:09:09+00:00

Has anyone had any luck with a vba macro that would convert this input:

  • 0

Has anyone had any luck with a vba macro that would convert this input:

update my_table 
    set time = sysdate, 
    randfield1 = 'FAKE', 
    randfield5 = 'ME', 
    the_field8 = 'test' 
    where my_key = '84' 
    ;

into this output?

select count(*) from my_table
where (randfield1 <> 'FAKE'
or randfield5 <> 'ME'
or the_field8 <> 'TEST')
and my_key = '84';

update (what happens when using Remou’s answer):

INPUT (what i have place in cell A1 of first sheet)-

update my_table  
    set time = sysdate,  
    randfield1 = 'FAKE',  
    randfield5 = 'ME',  
    the_field8 = 'test'  
    where my_key = '84'  
    ; 

OUTPUT (what is generated in a1 of the 2nd sheet once the macro is run)-

SELECT Count(*) FROM  my_table
WHERE ()
)
)
)
)
)
)
)
randfield1 <> 'FAKE'
OR )
)
)
)
randfield5 <> 'ME'
OR )
)
)
)
the_field8 <> 'test')
)
)
)
)
AND my_key = '84'
;
  • 1 1 Answer
  • 0 Views
  • 0 Followers
  • 0
Share
  • Facebook
  • Report

Leave an answer
Cancel reply

You must login to add an answer.

Forgot Password?

Need An Account, Sign Up Here

1 Answer

  • Voted
  • Oldest
  • Recent
  • Random
  1. Editorial Team
    Editorial Team
    2026-05-26T00:09:10+00:00Added an answer on May 26, 2026 at 12:09 am

    I am still not sure what you want, but anyway:

    Dim r As Range
    Dim cl As Range
    Dim s As String
    Dim c As String
    Dim arys As Variant
    Dim i As Long, j As Long
    
    ''Assuming an existing worksheet
    Set r = Sheet1.UsedRange
    j = Sheet2.UsedRange.Rows.Count
    
    For Each cl In r.Cells
        c = cl.Value
    
        ''Fake spaces
        Do While InStr(c, Chr(160)) > 0
            c = Replace(c, Chr(160), "")
        Loop
    
        ''Real spaces
        c = Trim(c)
    
        If c = ";" Then
    
            arys = Split(s, vbCrLf)
    
            For i = 0 To UBound(arys)
                Sheet2.Cells(j, 1) = arys(i)
                j = j + 1
            Next
    
            ''Layout
            j = j + 2
    
        ElseIf UCase(c) Like "UPDATE*" Then
    
            s = "SELECT Count(*) FROM " & Replace(c, "update", "", , , vbTextCompare)
            s = s & vbCrLf & "WHERE ("
    
        ElseIf UCase(c) Like "WHERE*" Then
            s = s & Replace(c, "where", "AND", , , vbTextCompare)
            s = s & vbCrLf & ";"
    
        ElseIf Left(UCase(c), 3) <> "SET" Then
            c = Replace(c, "=", "<>")
    
            If Right(c, 1) = "," Then
                s = s & Left(c, Len(c) - 1) & vbCrLf & "OR "
            Else
                s = s & c & ")" & vbCrLf
            End If
    
        End If
    Next
    
    • 0
    • Reply
    • Share
      Share
      • Share on Facebook
      • Share on Twitter
      • Share on LinkedIn
      • Share on WhatsApp
      • Report

Sidebar

Related Questions

Has anyone had any luck with querying/changing SPNs on a Windows domain? Most of
Has anyone had any luck running two instances of the iPhone simulator to test
Has anyone had any luck of using Oracle from .Net on a 64 bit
Has anyone had any luck rolling a custom GWT jar for Google Collections /
Has anyone had any experience targetting WSH in the way that VBScript , JScript
Has anyone had any luck installing Xcode 3.2.3 + iOS 4.0.2 SDK? I've tried
Has anyone had any luck getting MSMQ multicast (PGM) to bind to a specific
Has anyone had any luck using a UIPicker in the 3.2 SDK? I'm in
Has anyone had any luck getting encrypted streaming to work with Apple's HTTP Live
Has anyone had any luck integrating Twitpic's new OAuth Echo authentication into their iPhone

Explore

  • Home
  • Add group
  • Groups page
  • Communities
  • Questions
    • New Questions
    • Trending Questions
    • Must read Questions
    • Hot Questions
  • Polls
  • Tags
  • Badges
  • Users
  • Help
  • SEARCH

Footer

© 2021 The Archive Base. All Rights Reserved
With Love by The Archive Base

Insert/edit link

Enter the destination URL

Or link to existing content

    No search term specified. Showing recent items. Search or use up and down arrow keys to select an item.