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

  • Home
  • SEARCH
  • 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 8840987
In Process

The Archive Base Latest Questions

Editorial Team
  • 0
Editorial Team
Asked: June 14, 20262026-06-14T10:35:57+00:00 2026-06-14T10:35:57+00:00

I have a worksheet where each row (except the header) represents a single entry,

  • 0

I have a worksheet where each row (except the header) represents a single entry, each column a field (pretty standard stuff). The fields go up to column BB.

I want to copy certain entries (those matching a particular value for a particular identifying field) onto another sheet. However, I don’t want all the fields that are on the original sheet, only about 10, which aren’t contiguous on the original sheet.

Therefore, for each (valid) row, I would want to do something like this:

for each origRow in origSheet.Rows
    if strcomp(origRow.cells(idCellNumber).value, myId, vbTextCompare) = 0 then
        copySheet.Row(copySheetRowNumber).value = origRow.Range(Cells(1), Cells(8), Cells(15), Cells(4))
        copySheetRowNumber++
    end if
next

Obviously this code is invalid. Furthermore, I can’t simply copy the entries as a whole and then delete the irrelevant columns, since the sheet contains existing data which would be deleted. Can anyone suggest the fastest way to accomplish this?

  • 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-06-14T10:35:58+00:00Added an answer on June 14, 2026 at 10:35 am
    Dim arrSourceCols, arrDestCols
    Dim x As Long
    
    arrSourceCols = Array(1, 3, 5, 7)
    arrDestCols = Array(2, 4, 8, 12)
    
    For Each origRow In origSheet.UsedRange.Rows
        If StrComp(origRow.Cells(idCellNumber).Value, myId, vbTextCompare) = 0 Then
    
            For x = LBound(arrSourceCols) To UBound(arrSourceCols)
                copySheet.Cells(copySheetRowNumber, arrDestCols(x)).Value = _
                                      origRow.EntireRow.Cells(arrSourceCols(x)).Value
            Next x
    
            copySheetRowNumber = copySheetRowNumber + 1
        End If
    Next
    
    • 0
    • Reply
    • Share
      Share
      • Share on Facebook
      • Share on Twitter
      • Share on LinkedIn
      • Share on WhatsApp
      • Report

Sidebar

Related Questions

I have two excel files each with a single worksheet. I want to take
I have an Excel form which reads data from each row of an 80-row
I have a long row of data split into cells. Each cell populates a
I have a large data set with an identifier attributed to each row. There
How to add a simple header row on a programmaticaly created worksheet via Google
I have a worksheet that spans multiple pages, both vertically and horizontally. It has
I have the following Excel worksheet: | A B C -+--------------- 1|id date views
I have the following code: Private Sub SortWorksheet(ByVal sheet As Worksheet) Dim sStartColumn Dim
I have created a Userform that lets the user pick a worksheet from a
I have 2 worksheets, I need to update with data from another worksheet I

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.