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 6532937
In Process

The Archive Base Latest Questions

Editorial Team
  • 0
Editorial Team
Asked: May 25, 20262026-05-25T10:03:53+00:00 2026-05-25T10:03:53+00:00

if i have a sheet called ‘values’ with just 1 column with cells such

  • 0

if i have a sheet called ‘values’ with just 1 column with cells such as:

ColumnA
---------
emp_id
emp_name
dept_id

and then a 2nd sheet called ‘sql’ with 2 columns with cells such as:

ColumnA
--------
="select count(*) from tablex where "&a1&" is null;"
="select count(*) from tablex where length("&a1&") > 10;"

ColumnB
--------
Sheet for null
Sheet for length

What VBA macro code (note i need it in vba as i just want to click one button to generate the sheets) would i need to generate the following two output sheets (each sheet with just one column):

    Sheet for null
-------------------
select count(*) from tablex where emp_id is null;
select count(*) from tablex where emp_name is null;
select count(*) from tablex where dept_id is null;


    Sheet for length
-------------------
select count(*) from tablex where length(emp_id) > 10;
select count(*) from tablex where length(emp_name) > 10;
select count(*) from tablex where length(dept_id) > 10;
  • 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-25T10:03:54+00:00Added an answer on May 25, 2026 at 10:03 am

    I think this will do what you are asking.

    One change I made is that on the “sql” sheet, I changed the cell contents to look like this:

    ="select count(*) from tablex where variable is null;"
    

    so I used “variable” instead of “&a1&” like you originally had, and then in the code it replaces this word with the correct value of emp_id, emp_name, etc.

        Sub GenerateSheets()
        Dim formulaRange As Range
        Dim formula As String
        Dim r As Range
        Dim destloc As Range
        Dim VariableRange As Range
    
        Set formulaRange = Worksheets("sql").Cells(1, 1)
        ' get each formula
        Do Until formulaRange.Value = ""
            For Each r In formulaRange.Rows
                ' for each formula found, create a new sheet and move it to end
                Worksheets.Add
                ActiveSheet.Name = r.Offset(0, 1).Value
                ActiveSheet.Move after:=Sheets(ActiveWorkbook.Sheets.Count)
    
                Set destloc = ActiveSheet.Cells(1, 1)
                Set VariableRange = Worksheets("values").Cells(1.1)
                ' Loop through all the variables
                Do Until VariableRange.Value = ""
                    destloc.Value = Replace(formulaRange.Value, "variable", VariableRange.Value)
    
                    Set VariableRange = VariableRange.Offset(1, 0)
                    Set destloc = destloc.Offset(1, 0)
                Loop
            Next
    
            Set formulaRange = formulaRange.Offset(1, 0)
        Loop 
    End Sub
    
    • 0
    • Reply
    • Share
      Share
      • Share on Facebook
      • Share on Twitter
      • Share on LinkedIn
      • Share on WhatsApp
      • Report

Sidebar

Related Questions

I have a sheet called "main" that takes values from another file's sheet called
I have an Excel sheet with two column, one is a number , and
I have an Action Sheet that is called from my root view controller using
I have a list of numbers in an Excel sheet. I.e . one column
I have defined a Worksheet_Change sub on a sheet. It works fine. I just
I have a sheet with a custom button on it from where I control
I have a sheet full of some raw data, about 20,000 rows and 50
I have style sheet with a class name changebackgroundcolor i want make change in
Let say I have a sheet in with columns Customer and CreatedDate with lots
Here's what I have: Quarter Sheet Flyer (4 per page) as a PSD or

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.