Welcome to Experts Exchange

Add your voice to the tech community where 5M+ people, just like you, are talking about what matters.

  • Help others & share knowledge
  • Earn cash & points
  • Learn & ask questions
Solved

Excel showform modification

Posted on 2014-04-15
6
141 Views
Last Modified: 2014-04-15
Ken Butters formulated a solution to my previous question:
 http://www.experts-exchange.com/Software/Office_Productivity/Office_Suites/MS_Office/Excel/Q_28411230.html

The new example shows 29 columns on sheet 2 when there are many more. I've moved media to column AC. I'd like to know how to capture the data and blank spaces between column D and column AC of sheet2 using Mr. Butters showform macro. I am using Excel 2003, is this a limitation in this version of Excel?
TestBook1-Test.xls
showform1-detail-rev.txt
0
Comment
Question by:mfrax
  • 4
  • 2
6 Comments
 

Author Comment

by:mfrax
ID: 40002087
Attached is the original workbook with the showform recorded.
TestBook1-Result.xls
0
 
LVL 19

Accepted Solution

by:
Ken Butters earned 500 total points
ID: 40002096
The code that copies data from one sheet to another is this:

    j = 2
    For i = 2 To lastCellWk2.Row
        If SelectedCustomersDict.Exists(CStr(Wk2.Cells(i, 2).Value)) And Wk2.Cells(i, 29).Value = Me.cboMediaType.Value Then
            wk3.Range("B" & j & ":J" & j).Value = Wk2.Range("D" & i & ":AC" & i).Value
            j = j + 1
        End If
    Next

Open in new window


The specific line that actually does the copy is just this one:
            wk3.Range("B" & j & ":J" & j).Value = Wk2.Range("D" & i & ":AC" & i).Value

Open in new window


in the above single line of code the lower case 'j' is a variable that represents the rownumber of the destination sheet.

The lowercase 'i' is a variable that represents the rownumber of the source sheet.

So when a single row of data is copied the line of code would be the equivalent of something like this:

wk3.Range("B4:J4").Value = Wk2.Range("D2:AC2").Value

Open in new window


Now when you look at a specific example the problem becomes more evident... you are indicating that the data in columns D2 through AC2 get copied to columns B4 to J4.

D2 through AC2 contain 26 cells, where B4 through J4 only contain 9 cells.

If you make the destination of the copy contain the same number of cells as the source of the copy you should be good to go.

This modification should do it:

            wk3.Range("B" & j & ":AA" & j).Value = Wk2.Range("D" & i & ":AC" & i).Value

Open in new window

0
 

Author Comment

by:mfrax
ID: 40002317
Thank you for pointing out that I missed the beginning of that portion of the instruction. My mind missed that it was referring to wk3. When I modified the previous macro, it hadn't had that portion of the instruction.
0
Free Tool: IP Lookup

Get more info about an IP address or domain name, such as organization, abuse contacts and geolocation.

One of a set of tools we are providing to everyone as a way of saying thank you for being a part of the community.

 

Author Comment

by:mfrax
ID: 40002349
What does the instruction look like if it is similar to

Else if "all" or "All" then
End if

for example all media or all dates but only once per ID?
0
 
LVL 19

Expert Comment

by:Ken Butters
ID: 40002393
It would not be as simple as updating the If statement.

The current solution is not designed to be able to show all media types or all dates.

The current solution requires The selection of a single Media Type, and a Single date.

The way the dates/Media types in are being chosen in this solution, is via the combo boxes.  If you wanted to change the solution to be able to select multiple dates / multiple media types, several things would have to change:

1) Change from comboBox to Listbox
2) change property of listbox to allow multiple entries to be selected
3) change each step of logic to not just check for the single option selected, but for all selected options.
0
 

Author Closing Comment

by:mfrax
ID: 40002899
Clear and concise. Thanks.
0

Featured Post

Free Tool: Postgres Monitoring System

A PHP and Perl based system to collect and display usage statistics from PostgreSQL databases.

One of a set of tools we are providing to everyone as a way of saying thank you for being a part of the community.

Question has a verified solution.

If you are experiencing a similar issue, please ask a related question

Introduction While answering a recent question (http:/Q_27311462.html), I created an alternative function to the Excel Concatenate() function that you might find useful.  I tested several solutions and share the results in this article as well as t…
Freeze panes is an option within all variants of Excel to enable parts of a sheet to remain stationary when the cursor is in another part of the sheet. This is a very useful feature which is overlooked or under used.
This Micro Tutorial will demonstrate how to use a scrolling table in Microsoft Excel using the INDEX function.
Finds all prime numbers in a range requested and places them in a public primes() array. I've demostrated a template size of 30 (2 * 3 * 5) but larger templates can be built such 210  (2 * 3 * 5 * 7) or 2310  (2 * 3 * 5 * 7 * 11). The larger templa…

840 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