Hi Guys,
I'm pasting values from one sheet to another based on multiple named ranges. Woks great when pasting one column but when i add multiple ranges, UFFF!...
Read below...
General Overview:
I have a sample workbook attached, there are (2) sheets of importance.
First is the sheet (EstSummary) where I have miraculously been able to hack together coding a button control to import data from the (Svc) sheet.
The second Sheet (Svc) is a table of estimating service data that i have put together to input and price services.
I have created a number of named ranges (SvcDesc, SvcHdr, SvcQty, SvcSid, etc..)..
All the ranges above are single columns in the the Svc table and are dynamic leveraging the OFFSET function.
First issue: (Code in the import button.)
When I run this code to copy a single named range to the EstSummary Sheet, i have no issues pasting and re-pasting as the code checks for text and offsets one row past the next available cell row in that column.
When I augment the code to reference multiple named ranges, the first paste works great. But then if i hit the button again, it freezes in the loop and i have to force the app to close. I will be duplicating this button to pull from additional sheets like the (Svc) sheet so I am looking to fix the loop. I am JUST learning VB so I'm still very basic with my understanding.
=========================================================
==========================================================
Second issue: (Blanks in the named range)
In My SvcHdr named range there are sometimes blanks. I use this column in my data to help with conditional formatting of on the source and destination sheets. So someone who is preparing a quote can say "Well this row will serve as a header for the following rows." So this selection would be variable. I surmise that this issue exists for other named ranges as well as they may all not be populated with data all the way down the column.
The range should extend from C13:C55.. I use the header information for conditional formatting on both pages (H1 for example). So I may have it on C13 and again on C20, then C30.
The problem is that when there are blanks in between the rows the dynamic range extends only to the second occurance of the H1 value.
For instance, if I look at the range as it is set up above, it will show me that the range spans C13:C20.. It will not go past C20 to also cover C30 and down the rest of the column down to C55...
I guess i could work around this by setting a sheet macro that will look at that range and fill that column with "-" or something so that there is a value in the field. I tried to but i couldn't get it to work.
Stupid question, Is it possible to call the Full table named range (SvcFull) and just pull the data from the column in that range and paste it to the right columns in the destination sheet (EstSummary)?
It would be so much cleaner if i could just work with one named range for a set of page data and just call the columns i need rather than having to break out each column into different named range single columned data sets.
Any help would be appreciated.
Thanks,
P
I'm pasting values from one sheet to another based on multiple named ranges. Woks great when pasting one column but when i add multiple ranges, UFFF!...
Read below...
General Overview:
I have a sample workbook attached, there are (2) sheets of importance.
First is the sheet (EstSummary) where I have miraculously been able to hack together coding a button control to import data from the (Svc) sheet.
The second Sheet (Svc) is a table of estimating service data that i have put together to input and price services.
I have created a number of named ranges (SvcDesc, SvcHdr, SvcQty, SvcSid, etc..)..
All the ranges above are single columns in the the Svc table and are dynamic leveraging the OFFSET function.
First issue: (Code in the import button.)
When I run this code to copy a single named range to the EstSummary Sheet, i have no issues pasting and re-pasting as the code checks for text and offsets one row past the next available cell row in that column.
When I augment the code to reference multiple named ranges, the first paste works great. But then if i hit the button again, it freezes in the loop and i have to force the app to close. I will be duplicating this button to pull from additional sheets like the (Svc) sheet so I am looking to fix the loop. I am JUST learning VB so I'm still very basic with my understanding.
=========================================================
Code:
[FONT=Arial]Private Sub ProServices_Click()[/FONT]
[FONT=Arial]Dim RngToCopySID As Range[/FONT]
[FONT=Arial]Dim RngToCopyHdr As Range[/FONT]
[FONT=Arial]Dim RngToCopyQty As Range[/FONT]
[FONT=Arial]Dim RngToCopyDesc As Range[/FONT]
[FONT=Arial]Dim DestCellSid As Range[/FONT]
[FONT=Arial]Dim DestCellHdr As Range[/FONT]
[FONT=Arial]Dim DestCellQty As Range[/FONT]
[FONT=Arial]Dim DestCellDesc As Range[/FONT]
[FONT=Arial]With Worksheets("Svc")[/FONT]
[FONT=Arial]Set RngToCopySID = .Range("SvcSid")[/FONT]
[FONT=Arial]Set RngToCopyHdr = .Range("Svchdr")[/FONT]
[FONT=Arial]Set RngToCopyQty = .Range("SvcQty")[/FONT]
[FONT=Arial]Set RngToCopyDesc = .Range("SvcDesc")[/FONT]
[FONT=Arial]End With[/FONT]
[FONT=Arial]With Worksheets("EstSummary")[/FONT]
[FONT=Arial]Set DestCellSid = .Range("A21")[/FONT]
[FONT=Arial]Set DestCellHdr = .Range("B21")[/FONT]
[FONT=Arial]Set DestCellQty = .Range("C21")[/FONT]
[FONT=Arial]Set DestCellDesc = .Range("D21")[/FONT]
[FONT=Arial]End With[/FONT]
[FONT=Arial]Do[/FONT]
[FONT=Arial]If IsEmpty(DestCellSid.Value) Then[/FONT]
[FONT=Arial]If IsEmpty(DestCellHdr.Value) Then[/FONT]
[FONT=Arial]If IsEmpty(DestCellQty.Value) Then[/FONT]
[FONT=Arial]If IsEmpty(DestCellDesc.Value) Then[/FONT]
[FONT=Arial]Exit Do[/FONT]
[FONT=Arial]Else[/FONT]
[FONT=Arial]Set DestCellSid = DestCellDesc.Offset(2, 0)[/FONT]
[FONT=Arial]Set DestCellHdr = DestCellDesc.Offset(2, 0)[/FONT]
[FONT=Arial]Set DestCellQty = DestCellQty.Offset(2, 0)[/FONT]
[FONT=Arial]Set DestCellDesc = DestCellQty.Offset(2, 0)[/FONT]
[FONT=Arial]End If[/FONT]
[FONT=Arial]End If[/FONT]
[FONT=Arial]End If[/FONT]
[FONT=Arial]End If[/FONT]
[FONT=Arial]' This is where it gets stuck!!!! See below![/FONT]
[FONT=Arial]Loop [/FONT]
[FONT=Arial]RngToCopySID.Copy[/FONT]
[FONT=Arial]DestCellSid.PasteSpecial Paste:=xlPasteValues[/FONT]
[FONT=Arial]RngToCopyHdr.Copy[/FONT]
[FONT=Arial]DestCellHdr.PasteSpecial Paste:=xlPasteValues[/FONT]
[FONT=Arial]RngToCopyQty.Copy[/FONT]
[FONT=Arial]DestCellQty.PasteSpecial Paste:=xlPasteValues[/FONT]
[FONT=Arial]RngToCopyDesc.Copy[/FONT]
[FONT=Arial]DestCellDesc.PasteSpecial Paste:=xlPasteValues[/FONT]
[FONT=Arial]End Sub[/FONT]
==========================================================
Second issue: (Blanks in the named range)
In My SvcHdr named range there are sometimes blanks. I use this column in my data to help with conditional formatting of on the source and destination sheets. So someone who is preparing a quote can say "Well this row will serve as a header for the following rows." So this selection would be variable. I surmise that this issue exists for other named ranges as well as they may all not be populated with data all the way down the column.
The range should extend from C13:C55.. I use the header information for conditional formatting on both pages (H1 for example). So I may have it on C13 and again on C20, then C30.
The problem is that when there are blanks in between the rows the dynamic range extends only to the second occurance of the H1 value.
For instance, if I look at the range as it is set up above, it will show me that the range spans C13:C20.. It will not go past C20 to also cover C30 and down the rest of the column down to C55...
I guess i could work around this by setting a sheet macro that will look at that range and fill that column with "-" or something so that there is a value in the field. I tried to but i couldn't get it to work.
Stupid question, Is it possible to call the Full table named range (SvcFull) and just pull the data from the column in that range and paste it to the right columns in the destination sheet (EstSummary)?
It would be so much cleaner if i could just work with one named range for a set of page data and just call the columns i need rather than having to break out each column into different named range single columned data sets.
Any help would be appreciated.
Thanks,
P