Solved

Data Refresh Excel in line with manually entered data?

Posted on 2014-01-21
6
269 Views
Last Modified: 2014-01-28
Attached is an example of the worksheet I need to update.

Columns A&B need to come from the database to ensure all the specifications are being addressed and Columns C thru Z are manually entered.

I have the query that refreshes Columns A & B, keeping the sort and I have the vba (not in the example) to insert an empty row on the change of Category.

What I don't have is when A&B are refreshed, how do I keep the manually entered column data with the appropriate Column A&B information?

Also, is it possible to enter the blank rows and populate the Category name (as in the example?)

Thanks for your help....
Worksheet-Example.xlsm
0
Comment
Question by:urthrilled
  • 4
  • 2
6 Comments
 
LVL 10

Expert Comment

by:SANTABABY
Comment Utility
I can provide a complete and tested solution of you can provide the code/macro that you are using.
Here is something to give you an idea. This code has some holes to handle your section breaks and you need to use markers to define section boundaries in your worksheet and enhance the code accordingly.

Option Base 1
'Items array(2,x) contains Item No and Desc
Sub UpdateSpec(Items() As Variant)
Dim i As Integer, j As Integer, cnt As Integer
Dim ws As Worksheet
  Set ws = ActiveSheet
  i = LBound(Items(1))
  cnt = UBound(Items(1))
  j = 14
  While i <= cnt
    If ws.Cells(j, 1) = "" And ws.Cells(j + 1, 1) <> "" Then j = j + 1
    If Items(1, i) < ws.Cells(j, 1) Or _
        (ws.Cells(j + 1, 1) = "" And (ws.Cells(j + 2, 1) = "" Or Items(1, i) < ws.Cells(j + 2, 1))) Then
        ws.Rows(j).Insert Shift:=xlDown
        ws.Cells(j, 1) = Items(1, i)
        ws.Cells(j, 2) = Items(2, i)
        i = i + 1
        j = j + 1
    ElseIf Items(1, i) < ws.Cells(j, 1) Then
        j = j + 1
        i = i + 1
    Else
        ws.Rows(j).Delete
    End If
  Wend
End Sub
0
 
LVL 4

Author Comment

by:urthrilled
Comment Utility
I've attached the workbook with Sheet2, which has the sql data and the macro to insert the blank rows.

I only need the 2 columns, SpecNo and Item_Description, but I included the other information to be used in other ways (i.e. the Category_Description is the Group Name that should go in the blank row)

I see in the Properties of the Connection in Excel it has choices to update and/or insert, but I don't believe that's robust enough for this purpose?
0
 
LVL 4

Author Comment

by:urthrilled
Comment Utility
Oops, I forgot to attach the file....  here it is
Worksheet-Example.xlsm
0
Why You Should Analyze Threat Actor TTPs

After years of analyzing threat actor behavior, it’s become clear that at any given time there are specific tactics, techniques, and procedures (TTPs) that are particularly prevalent. By analyzing and understanding these TTPs, you can dramatically enhance your security program.

 
LVL 4

Accepted Solution

by:
urthrilled earned 0 total points
Comment Utility
What do you think about a vba command to insert spec numbers in a coumn that's not included in the refresh so that once the update happens the rows can be sorted and reunited?
0
 
LVL 10

Expert Comment

by:SANTABABY
Comment Utility
Just got busy with some day long meetings. Very glad to hear that you have a good handle on the issue. Good luck.
0
 
LVL 4

Author Closing Comment

by:urthrilled
Comment Utility
After working with it, the way to work it out became clear
0

Featured Post

Maximize Your Threat Intelligence Reporting

Reporting is one of the most important and least talked about aspects of a world-class threat intelligence program. Here’s how to do it right.

Join & Write a Comment

Article by: Leon
Software Metering within our group of companies has always been an afterthought until auditing of software and licensing became a pain point. Orchestrator and SCCM metering gave us the answer and it was an exciting process.
This code takes an Excel list of URL’s and adds a header titled “URL List”. It then searches through all URL’s in column “A”, looking for duplicates. When a duplicate is found, it is moved to the top of the list. The duplicate URL’s are then highlig…
The viewer will learn how to  create a slide that will launch other presentations in Microsoft PowerPoint. In the finished slide, each item launches a new PowerPoint presentation and when each is finished it automatically comes back to this slide: …
This Micro Tutorial demonstrates how to create Excel charts: column, area, line, bar, and scatter charts. Formatting tips are provided as well.

772 members asked questions and received personalized solutions in the past 7 days.

Join the community of 500,000 technology professionals and ask your questions.

Join & Ask a Question

Need Help in Real-Time?

Connect with top rated Experts

10 Experts available now in Live!

Get 1:1 Help Now