Home |
Search |
Today's Posts |
|
#1
![]()
Posted to microsoft.public.excel.worksheet.functions
|
|||
|
|||
![]()
Hello,
I have a worksheet with detail data in sheet1 that I'd like to pull over email add'y in sheet2 if cells in colA are null. Can this be done via a formula or vba? I'm currently using a pivot table but because we have such a large volume of data we have poor performance. COL A COL B COL A (sheet2) 0609 0609 0607 0609 Thank you! Cathy |
#2
![]()
Posted to microsoft.public.excel.worksheet.functions
|
|||
|
|||
![]()
I'm a little confused as to which way data is supposed to be moved. Looking
at your example, I'm thinking you want to get an email address from column A of Sheet2 and place it into empty cells in column B of Sheet1. Question is how to decide which one to pull. Is there a one-to-one correspondence between the rows on both sheets. That is, if Sheet1!B3 is empty, can we just get the address in Sheet2!B3 to put into it? By any chance would the numbers shown as being in Sheet1, column A be found on Sheet2 in association with the appropriate email addresses? "Cathy Landry" wrote: Hello, I have a worksheet with detail data in sheet1 that I'd like to pull over email add'y in sheet2 if cells in colA are null. Can this be done via a formula or vba? I'm currently using a pivot table but because we have such a large volume of data we have poor performance. COL A COL B COL A (sheet2) 0609 0609 0607 0609 Thank you! Cathy |
#3
![]()
Posted to microsoft.public.excel.worksheet.functions
|
|||
|
|||
![]()
Hello,
Sheet1 Column A will always contain a mm/yy (we use this for our corp card programs exp date) Column B will always contain employees email add'y. So, I'd like to create an email list in sheet2 of all email addresses where the cells in ColA in Sheet1 are not null. Hope that makes sense :) "JLatham" wrote: I'm a little confused as to which way data is supposed to be moved. Looking at your example, I'm thinking you want to get an email address from column A of Sheet2 and place it into empty cells in column B of Sheet1. Question is how to decide which one to pull. Is there a one-to-one correspondence between the rows on both sheets. That is, if Sheet1!B3 is empty, can we just get the address in Sheet2!B3 to put into it? By any chance would the numbers shown as being in Sheet1, column A be found on Sheet2 in association with the appropriate email addresses? "Cathy Landry" wrote: Hello, I have a worksheet with detail data in sheet1 that I'd like to pull over email add'y in sheet2 if cells in colA are null. Can this be done via a formula or vba? I'm currently using a pivot table but because we have such a large volume of data we have poor performance. COL A COL B COL A (sheet2) 0609 0609 0607 0609 Thank you! Cathy |
#4
![]()
Posted to microsoft.public.excel.worksheet.functions
|
|||
|
|||
![]()
Make a copy of your workbook and test this out in it first. Change the names
of the two worksheets in this code to whatever they're really called in the workbook. To put the code where you can use it, press [Alt]+[F11] to open the VB editor. Choose Insert Module from the VBE menu. Copy and paste the code below into the module that appears, make the sheet name changes, close the VB Editor and use it from Tools Macro Macros. I assumed you wanted the email addresses to actually be email links, so I've coded it that way. Sub MakeEmailList() Const sourceSheet = "Sheet1" ' change Const emailListSheet = "Sheet2" ' change Dim lastSourceRow As Long Dim sourcePointer As Long Dim srcRange As Range Dim emailRange As Range Dim emailPointer As Long If Val(Left(Application.Version, 2)) < 12 Then 'in pre-2007 Excel lastSourceRow = Worksheets(sourceSheet).Range("A" & _ Rows.Count).End(xlUp).Row emailPointer = Worksheets(emailListSheet).Range("A" & _ Rows.Count).End(xlUp).Row Else 'in Excel 2007 (or later) lastSourceRow = Worksheets(sourceSheet).Range("A" & _ Rows.CountLarge).End(xlUp).Row emailPointer = Worksheets(emailListSheet).Range("A" & _ Rows.CountLarge).End(xlUp).Row End If Set srcRange = Worksheets(sourceSheet).Range("A1") Set emailRange = Worksheets(emailListSheet).Range("A1") Do While srcRange.Row + sourcePointer <= lastSourceRow If Not IsEmpty(srcRange.Offset(sourcePointer, 0)) Then 'some entry in column A 'if also an entry in B, assume an email, copy it If Not IsEmpty(srcRange.Offset(sourcePointer, 1)) Then emailRange.Offset(emailPointer, 0).Hyperlinks.Add _ Anchor:=emailRange.Offset(emailPointer, 0), _ Address:="mailto:" & srcRange.Offset(sourcePointer, 1).Value, _ TextToDisplay:=srcRange.Offset(sourcePointer, 1).Value emailPointer = emailPointer + 1 End If End If sourcePointer = sourcePointer + 1 Loop End Sub "Cathy Landry" wrote: Hello, Sheet1 Column A will always contain a mm/yy (we use this for our corp card programs exp date) Column B will always contain employees email add'y. So, I'd like to create an email list in sheet2 of all email addresses where the cells in ColA in Sheet1 are not null. Hope that makes sense :) "JLatham" wrote: I'm a little confused as to which way data is supposed to be moved. Looking at your example, I'm thinking you want to get an email address from column A of Sheet2 and place it into empty cells in column B of Sheet1. Question is how to decide which one to pull. Is there a one-to-one correspondence between the rows on both sheets. That is, if Sheet1!B3 is empty, can we just get the address in Sheet2!B3 to put into it? By any chance would the numbers shown as being in Sheet1, column A be found on Sheet2 in association with the appropriate email addresses? "Cathy Landry" wrote: Hello, I have a worksheet with detail data in sheet1 that I'd like to pull over email add'y in sheet2 if cells in colA are null. Can this be done via a formula or vba? I'm currently using a pivot table but because we have such a large volume of data we have poor performance. COL A COL B COL A (sheet2) 0609 0609 0607 0609 Thank you! Cathy |
#5
![]()
Posted to microsoft.public.excel.worksheet.functions
|
|||
|
|||
![]()
Works beautifully!!!!!!
Thank you :) "JLatham" wrote: Make a copy of your workbook and test this out in it first. Change the names of the two worksheets in this code to whatever they're really called in the workbook. To put the code where you can use it, press [Alt]+[F11] to open the VB editor. Choose Insert Module from the VBE menu. Copy and paste the code below into the module that appears, make the sheet name changes, close the VB Editor and use it from Tools Macro Macros. I assumed you wanted the email addresses to actually be email links, so I've coded it that way. Sub MakeEmailList() Const sourceSheet = "Sheet1" ' change Const emailListSheet = "Sheet2" ' change Dim lastSourceRow As Long Dim sourcePointer As Long Dim srcRange As Range Dim emailRange As Range Dim emailPointer As Long If Val(Left(Application.Version, 2)) < 12 Then 'in pre-2007 Excel lastSourceRow = Worksheets(sourceSheet).Range("A" & _ Rows.Count).End(xlUp).Row emailPointer = Worksheets(emailListSheet).Range("A" & _ Rows.Count).End(xlUp).Row Else 'in Excel 2007 (or later) lastSourceRow = Worksheets(sourceSheet).Range("A" & _ Rows.CountLarge).End(xlUp).Row emailPointer = Worksheets(emailListSheet).Range("A" & _ Rows.CountLarge).End(xlUp).Row End If Set srcRange = Worksheets(sourceSheet).Range("A1") Set emailRange = Worksheets(emailListSheet).Range("A1") Do While srcRange.Row + sourcePointer <= lastSourceRow If Not IsEmpty(srcRange.Offset(sourcePointer, 0)) Then 'some entry in column A 'if also an entry in B, assume an email, copy it If Not IsEmpty(srcRange.Offset(sourcePointer, 1)) Then emailRange.Offset(emailPointer, 0).Hyperlinks.Add _ Anchor:=emailRange.Offset(emailPointer, 0), _ Address:="mailto:" & srcRange.Offset(sourcePointer, 1).Value, _ TextToDisplay:=srcRange.Offset(sourcePointer, 1).Value emailPointer = emailPointer + 1 End If End If sourcePointer = sourcePointer + 1 Loop End Sub "Cathy Landry" wrote: Hello, Sheet1 Column A will always contain a mm/yy (we use this for our corp card programs exp date) Column B will always contain employees email add'y. So, I'd like to create an email list in sheet2 of all email addresses where the cells in ColA in Sheet1 are not null. Hope that makes sense :) "JLatham" wrote: I'm a little confused as to which way data is supposed to be moved. Looking at your example, I'm thinking you want to get an email address from column A of Sheet2 and place it into empty cells in column B of Sheet1. Question is how to decide which one to pull. Is there a one-to-one correspondence between the rows on both sheets. That is, if Sheet1!B3 is empty, can we just get the address in Sheet2!B3 to put into it? By any chance would the numbers shown as being in Sheet1, column A be found on Sheet2 in association with the appropriate email addresses? "Cathy Landry" wrote: Hello, I have a worksheet with detail data in sheet1 that I'd like to pull over email add'y in sheet2 if cells in colA are null. Can this be done via a formula or vba? I'm currently using a pivot table but because we have such a large volume of data we have poor performance. COL A COL B COL A (sheet2) 0609 0609 0607 0609 Thank you! Cathy |
#6
![]()
Posted to microsoft.public.excel.worksheet.functions
|
|||
|
|||
![]()
You're welcome, enjoy!
"Cathy Landry" wrote: Works beautifully!!!!!! Thank you :) "JLatham" wrote: Make a copy of your workbook and test this out in it first. Change the names of the two worksheets in this code to whatever they're really called in the workbook. To put the code where you can use it, press [Alt]+[F11] to open the VB editor. Choose Insert Module from the VBE menu. Copy and paste the code below into the module that appears, make the sheet name changes, close the VB Editor and use it from Tools Macro Macros. I assumed you wanted the email addresses to actually be email links, so I've coded it that way. Sub MakeEmailList() Const sourceSheet = "Sheet1" ' change Const emailListSheet = "Sheet2" ' change Dim lastSourceRow As Long Dim sourcePointer As Long Dim srcRange As Range Dim emailRange As Range Dim emailPointer As Long If Val(Left(Application.Version, 2)) < 12 Then 'in pre-2007 Excel lastSourceRow = Worksheets(sourceSheet).Range("A" & _ Rows.Count).End(xlUp).Row emailPointer = Worksheets(emailListSheet).Range("A" & _ Rows.Count).End(xlUp).Row Else 'in Excel 2007 (or later) lastSourceRow = Worksheets(sourceSheet).Range("A" & _ Rows.CountLarge).End(xlUp).Row emailPointer = Worksheets(emailListSheet).Range("A" & _ Rows.CountLarge).End(xlUp).Row End If Set srcRange = Worksheets(sourceSheet).Range("A1") Set emailRange = Worksheets(emailListSheet).Range("A1") Do While srcRange.Row + sourcePointer <= lastSourceRow If Not IsEmpty(srcRange.Offset(sourcePointer, 0)) Then 'some entry in column A 'if also an entry in B, assume an email, copy it If Not IsEmpty(srcRange.Offset(sourcePointer, 1)) Then emailRange.Offset(emailPointer, 0).Hyperlinks.Add _ Anchor:=emailRange.Offset(emailPointer, 0), _ Address:="mailto:" & srcRange.Offset(sourcePointer, 1).Value, _ TextToDisplay:=srcRange.Offset(sourcePointer, 1).Value emailPointer = emailPointer + 1 End If End If sourcePointer = sourcePointer + 1 Loop End Sub "Cathy Landry" wrote: Hello, Sheet1 Column A will always contain a mm/yy (we use this for our corp card programs exp date) Column B will always contain employees email add'y. So, I'd like to create an email list in sheet2 of all email addresses where the cells in ColA in Sheet1 are not null. Hope that makes sense :) "JLatham" wrote: I'm a little confused as to which way data is supposed to be moved. Looking at your example, I'm thinking you want to get an email address from column A of Sheet2 and place it into empty cells in column B of Sheet1. Question is how to decide which one to pull. Is there a one-to-one correspondence between the rows on both sheets. That is, if Sheet1!B3 is empty, can we just get the address in Sheet2!B3 to put into it? By any chance would the numbers shown as being in Sheet1, column A be found on Sheet2 in association with the appropriate email addresses? "Cathy Landry" wrote: Hello, I have a worksheet with detail data in sheet1 that I'd like to pull over email add'y in sheet2 if cells in colA are null. Can this be done via a formula or vba? I'm currently using a pivot table but because we have such a large volume of data we have poor performance. COL A COL B COL A (sheet2) 0609 0609 0607 0609 Thank you! Cathy |
Reply |
Thread Tools | Search this Thread |
Display Modes | |
|
|
![]() |
||||
Thread | Forum | |||
Convert a Number Code to a Text Code | Excel Discussion (Misc queries) | |||
Unprotect Code Module in Code | Excel Discussion (Misc queries) | |||
Need 2 add second then third code with first code in the Tab View | Excel Worksheet Functions | |||
copying vba code to a standard code module | Excel Discussion (Misc queries) | |||
Write a code by code | Excel Discussion (Misc queries) |