Since you have opened up my eyes about what Excel can do, dealing with that same file system the columns that do not have data to import I have to enter manually for example
Column E (type) I can put either Coupon or offer
Column V (post_type) needs the word post
Column W (post_status) should have the word publish
Can this also be done?
Column E, no, Excel won't know whether you want "coupon" or "offer"
Column V and W, sure, since it's the same for all rows...
Option Explicit Sub ImportNewSKUData() 'Imports a file you select into the activesheet Dim wb1 As Workbook, wsNEW As Worksheet Dim LR As Long, fNAME As String If MsgBox("Process data into the activesheet?", _ vbYesNo, "Confirm") = vbNo Then Exit Sub Set wsNEW = ActiveSheet fNAME = Application.GetOpenFilename("Microsoft Office Excel Files (.xls),.xls") If fNAME = "False" Then Exit Sub On Error Resume Next Set wb1 = Workbooks.Open(fNAME) wsNEW.UsedRange.Offset(1).ClearContents With wb1.Sheets("Sheet1") LR = .Range("A" & .Rows.Count).End(xlUp).Row .Range("H2:H" & LR).Copy wsNEW.Range("A2") 'SKU>SKU .Range("E2:E" & LR).Copy wsNEW.Range("B2") 'NAME>post_title .Range("G2:G" & LR).Copy wsNEW.Range("C2") 'DESCRIPTION>post_content .Range("E2:E" & LR).Copy wsNEW.Range("D2") 'NAME>post_excerpt .Range("B2:B" & LR).Copy wsNEW.Range("M2") 'PROGRAMURL>url .Range("R2:R" & LR).Copy wsNEW.Range("N2") 'BUYURL>link .Range("T2:T" & LR).Copy wsNEW.Range("S2:T2") 'IMAGEURL>image & images .Range("C2:C" & LR).Copy wsNEW.Range("U2") 'CATALOGNAME>category .Range("F2:F" & LR).Copy wsNEW.Range("X2") 'KEYWORDS>tags End With wb1.Close False LR = Range("A" & Rows.Count).End(xlUp).Row Range("V2:V" & LR).Value = "post" Range("W2:W" & LR).Value = "publish" End Sub
_________________
Microsoft MVP 2010 - Excel
Visit: Jerry Beaucaire's Excel Files & Macros
If you've been given good help, use theicon below to give reputation feedback, it is appreciated.
Always put your code between code tags. [CODE] your code here [/CODE]
“None of us is as good as all of us” - Ray Kroc
“Actually, I *am* a rocket scientist.” - JB (little ones count!)
Jerry,
I have run across another issue that I think you can help me with, some of my files are larger then 65536 line can we write into the macro that if it is more then 65536 then it will split it up into multi workbooks that are say 30,000 each or something like that.
Off hand, there's nothing in this entire project that is compatible with that idea. You are opening one workbook and mapping the data into another workbook in a specific order.... you are opening the workbooks and copy data around ... so you can't open workbooks with more than 65k rows of data.
If your data is in files longer that 65k rows of data, upgrade to Excel 2007 or higher, this is a business expense, and a minor one.
Once you are able to open these Excel files of greater length, then you could break it down into smaller subsets of 30k rows.
_________________
Microsoft MVP 2010 - Excel
Visit: Jerry Beaucaire's Excel Files & Macros
If you've been given good help, use theicon below to give reputation feedback, it is appreciated.
Always put your code between code tags. [CODE] your code here [/CODE]
“None of us is as good as all of us” - Ray Kroc
“Actually, I *am* a rocket scientist.” - JB (little ones count!)
Thank You,
I am in need of an update on my macro,
The code is below at bottom...
What I need help with is.
1) Column (O) needs to say "Active" from O2: to the end of the sheet.
2) Column (P) needs to say "Yes" from P2: to the end of the sheet.
3) Column (AK) needs to have either the number (1) or (0)
4) Column (AL) needs to have either the number (1) or (0)
5) Column (AP) needs to have options (Merchant Coupon) (Offers) (Deals)
On the last one you did for me you used the following. but it does not seam to work with Excel 2007
I was using 2003 before.
This is what I have so far and it does most of the job but I can't get the rest to work.wb1.Close False LR = Range("A" & Rows.Count).End(xlUp).Row Range("E2:E" & LR).Value = "offer" Range("V2:V" & LR).Value = "post" Range("W2:W" & LR).Value = "publish"
Option Explicit Sub PHPIMPORT() 'Imports a file you select into the activesheet Dim wb1 As Workbook, wsNEW As Worksheet Dim LR As Long, fNAME As String If MsgBox("Process data into the activesheet?", _ vbYesNo, "Confirm") = vbNo Then Exit Sub Set wsNEW = ActiveSheet fNAME = Application.GetOpenFilename("Microsoft Office Excel Files (.xls),.xls") If fNAME = "False" Then Exit Sub On Error Resume Next Set wb1 = Workbooks.Open(fNAME) wsNEW.UsedRange.Offset(1).ClearContents With wb1.Sheets("Sheet1") LR = .Range("A" & .Rows.Count).End(xlUp).Row .Range("E2:E" & LR).Copy wsNEW.Range("B2") 'NAME>TITLE .Range("G2:G" & LR).Copy wsNEW.Range("C2") 'DESCRIPTION>DESCRIPTION .Range("E2:E" & LR).Copy wsNEW.Range("BD2") 'NAME>MCOUPON_TAG .Range("B2:B" & LR).Copy wsNEW.Range("D2") 'PROGRAMURL>URL .Range("R2:R" & LR).Copy wsNEW.Range("BC2") 'BUYURL>AFFURL .Range("R2:R" & LR).Copy wsNEW.Range("BE2") 'BUYURL>MCOUPON_URL .Range("T2:T" & LR).Copy wsNEW.Range("BI2") 'IMAGEURL>MCOUPON_LOGO .Range("C2:C" & LR).Copy wsNEW.Range("L2") 'CATALOGNAME>CATEGORY_ID .Range("F2:F" & LR).Copy wsNEW.Range("AT2") 'KEYWORDS>META_KEYWORDS .Range("G2:G" & LR).Copy wsNEW.Range("BG2") 'DESCRIPTION>MCOUPON_DESC .Range("N2:N" & LR).Copy wsNEW.Range("AW2") 'SALEPRICE>PRICE .Range("T2:T" & LR).Copy wsNEW.Range("AX2") 'IMAGEURL>IMAGE .Range("C2:C" & LR).Copy wsNEW.Range("AZ2") 'CATALOGNAME>STORE_ID End With wb1.Close False End Sub
Last edited by Paul; 04-11-2012 at 07:04 PM. Reason: Added CODE tags. Please remember to do this yourself in the future.
Maybe:
wb1.Close False With wsNEW LR = .Range("A" & .Rows.Count).End(xlUp).Row .Range("E2:E" & LR).Value = "offer" .Range("V2:V" & LR).Value = "post" .Range("W2:W" & LR).Value = "publish" End With
_________________
Microsoft MVP 2010 - Excel
Visit: Jerry Beaucaire's Excel Files & Macros
If you've been given good help, use theicon below to give reputation feedback, it is appreciated.
Always put your code between code tags. [CODE] your code here [/CODE]
“None of us is as good as all of us” - Ray Kroc
“Actually, I *am* a rocket scientist.” - JB (little ones count!)
That code is for another macro.
The new macro needs something similar
1) Column (O) needs to say "Active" from O2: to the end of the sheet.
2) Column (P) needs to say "Yes" from P2: to the end of the sheet.
3) Column (AK) needs to have either the number (1)
4) Column (AL) needs to have either the number (1)
5) Column (AP) needs to have options (Merchant Coupon)
So if I follow you it should look like this
_______________________________________________________
wb1.Close False
With wsNEW
LR = .Range("A" & .Rows.Count).End(xlUp).Row
.Range("O2:O" & LR).Value = "Active"
.Range("P2:P" & LR).Value = "Yes"
.Range("AK2:AK" & LR).Value = "1"
.Range("AL2:AL" & LR).Value = "1"
.Range("AP2:AP" & LR).Value = "Merchant Coupon"
End With
_______________________________________________________
I'm not sure what you mean by "needs to have the options (Merchant Coupon)", but as for the rest, that looks right. When you tested it?
_________________
Microsoft MVP 2010 - Excel
Visit: Jerry Beaucaire's Excel Files & Macros
If you've been given good help, use theicon below to give reputation feedback, it is appreciated.
Always put your code between code tags. [CODE] your code here [/CODE]
“None of us is as good as all of us” - Ray Kroc
“Actually, I *am* a rocket scientist.” - JB (little ones count!)
"needs to have the options (Merchant Coupon)", I had 3 options but I forgot the last time you helped me you stated that I would not be able to pick the option I needed.
Here is the sheet after i run the macro.
1) You can possibly pick the options you need if you explain them, demonstrate them fully in these same sheets you're uploading.
2) The sheet you uploaded in #25 doesn't have any code for me to troubleshoot.
3) The code snippet I gave you in #22 shows how to insert values in Row2:LastRowOfData, but your sample sheet from #25 shows your gray cells as being pasted into Row1, so your application of the code I gave you has been edited.
_________________
Microsoft MVP 2010 - Excel
Visit: Jerry Beaucaire's Excel Files & Macros
If you've been given good help, use theicon below to give reputation feedback, it is appreciated.
Always put your code between code tags. [CODE] your code here [/CODE]
“None of us is as good as all of us” - Ray Kroc
“Actually, I *am* a rocket scientist.” - JB (little ones count!)
OK, Let me start from scratch sheet 1 will be the file I need to convert, sheet 2 will be the import fields, sheet 3 will be the macro code, and there is a image of the idea if it is possible.
What I need is for
Cell (O2) to have the word "Active"
Cell (P2) to have a choice of "Yes" or "No" --- Maybe a box could pop up and I have to pick one.
Cell (AK2) to have a choice of "Yes" or "No" ---
Cell (AL2) to have a choice of "Yes" or "No" ---
Cell (AP2) to have a choice of "Deals" , "Offer" or "Merchant Coupon" ---
If it is possible to have a box pop up with check box's (see image)
I hope this helps and thank you very much
**** ALSO EVERY TIME I OPEN EXCEL THE FILE (PERSONAL) OPENS SO I HAVE TO CLOSE THAT FILE AND CLICK NEW ***
Can you please tell me how to disable that.excel-pop-up-box.gifSheet 1.xlsSheet 2.xlsm
You can use popup questions like so.. this shows you first how to apply a simple data validation drop down selection box to a range of cells, and since there are only a couple of choices, a neat trick for using the YES/NO buttons on a standard Excel MsgBox to make the default choices:
'Column P example With Range("P2:P" & LR).Validation .Delete .Add Type:=xlValidateList, AlertStyle:=xlValidAlertStop, Operator:=xlBetween, Formula1:="Yes, No" .IgnoreBlank = True .InCellDropdown = True .InputTitle = "" .ErrorTitle = "" .InputMessage = "" .ErrorMessage = "" .ShowInput = True .ShowError = True .Parent.Value = WorksheetFunction.Lookup(MsgBox("Click the button that will be the default value for Column P", vbYesNo), Array(6, 7), Array("Yes", "No")) End With 'Column AP example With Range("AP2:AP" & LR).Validation .Delete .Add Type:=xlValidateList, AlertStyle:=xlValidAlertStop, Operator:=xlBetween, Formula1:="Deals, Offer, Merchant Coupon" .IgnoreBlank = True .InCellDropdown = True .InputTitle = "" .ErrorTitle = "" .InputMessage = "" .ErrorMessage = "" .ShowInput = True .ShowError = True .Parent.Value = WorksheetFunction.Lookup(MsgBox("Click the button that will be the default value for Column P" _ & vbLf & vbLf & "Yes = 'Deals'" & vbLf & "No = 'Offer'" & vbLf & "Cancel = 'Merchant Coupon'", vbYesNoCancel, "Choose"), _ Array(2, 6, 7), Array("Merchant Coupon", "Deals", "Offer")) End With
_________________
Microsoft MVP 2010 - Excel
Visit: Jerry Beaucaire's Excel Files & Macros
If you've been given good help, use theicon below to give reputation feedback, it is appreciated.
Always put your code between code tags. [CODE] your code here [/CODE]
“None of us is as good as all of us” - Ray Kroc
“Actually, I *am* a rocket scientist.” - JB (little ones count!)
Is this everything I need or just an example?
I ran it the way it is and I get a compile error with this line.
.Parent.Value = WorksheetFunction.Lookup(MsgBox("Click the button that will be the default value for Column P", vbYesNo), Array(6, 7), Array("Yes", "No")) End With
So I'm not sure what happened but nothing went into (P), nothing went into (O), nothing went into (AK), nothing went into (AL) & nothing went into (AP)...
The worksheet that needed to imported had some information in it but it was all wrong.
I'm not sure what all the commands are for so I can't try and figure it out myself. I will give it my best try and maybe you can correct my errors.
This is what I need added to the original sheet you made me.
Cell (O2) to have the word "Active"
Cell (P2) to have a choice of "Yes" or "No" --- Maybe a box could pop up and I have to pick one.
Cell (AK2) to have a choice of "Yes" or "No" ---
Cell (AL2) to have a choice of "Yes" or "No" ---
Cell (AP2) to have a choice of "Deals" , "Offer" or "Merchant Coupon" ---
Here is the one you made me before. I changed a few thing to work with my new format but this part works great.
Sub PHPIMPORT()
'Imports a file you select into the activesheet
Dim wb1 As Workbook, wsNEW As Worksheet
Dim LR As Long, fNAME As String
If MsgBox("Process data into the activesheet?", _
vbYesNo, "Confirm") = vbNo Then Exit Sub
Set wsNEW = ActiveSheet
fNAME = Application.GetOpenFilename("Microsoft Office Excel Files (.xls),.xls")
If fNAME = "False" Then Exit Sub
On Error Resume Next
Set wb1 = Workbooks.Open(fNAME)
wsNEW.UsedRange.Offset(1).ClearContents
With wb1.Sheets("Sheet1")
LR = .Range("A" & .Rows.Count).End(xlUp).Row
.Range("E2:E" & LR).Copy wsNEW.Range("B2") 'NAME>TITLE
.Range("G2:G" & LR).Copy wsNEW.Range("C2") 'DESCRIPTION>DESCRIPTION
.Range("E2:E" & LR).Copy wsNEW.Range("BD2") 'NAME>MCOUPON_TAG
.Range("B2:B" & LR).Copy wsNEW.Range("D2") 'PROGRAMURL>URL
.Range("R2:R" & LR).Copy wsNEW.Range("BC2") 'BUYURL>AFFURL
.Range("R2:R" & LR).Copy wsNEW.Range("BE2") 'BUYURL>MCOUPON_URL
.Range("T2:T" & LR).Copy wsNEW.Range("BI2") 'IMAGEURL>MCOUPON_LOGO
.Range("C2:C" & LR).Copy wsNEW.Range("L2") 'CATALOGNAME>CATEGORY_ID
.Range("F2:F" & LR).Copy wsNEW.Range("AT2") 'KEYWORDS>META_KEYWORDS
.Range("G2:G" & LR).Copy wsNEW.Range("BG2") 'DESCRIPTION>MCOUPON_DESC
.Range("N2:N" & LR).Copy wsNEW.Range("AW2") 'SALEPRICE>PRICE
.Range("T2:T" & LR).Copy wsNEW.Range("AX2") 'IMAGEURL>IMAGE
.Range("C2:C" & LR).Copy wsNEW.Range("AZ2") 'CATALOGNAME>STORE_ID
End With
Now I will try and do as much as I can.
wb1.Close False
LR = Range("A" & Rows.Count).End(xlUp).Row
Range("O2:O" & LR).Value = "Active"
Range("P2:P" & LR).Validation
.Delete
.Add Type:=xlValidateList, AlertStyle:=xlValidAlertStop, Operator:=xlBetween, Formula1:="Yes, No"
.IgnoreBlank = True
.InCellDropdown = True
.InputTitle = ""
.ErrorTitle = ""
.InputMessage = ""
.ErrorMessage = ""
.ShowInput = True
.ShowError = True
.Parent.Value = WorksheetFunction.Lookup(MsgBox("Click the button that will be the default value for Column P", vbYesNo), Array(6, 7), Array("Yes", "No"))
End With
Range("AK2:AK" & LR).Validation
.Delete
.Add Type:=xlValidateList, AlertStyle:=xlValidAlertStop, Operator:=xlBetween, Formula1:="Yes, No"
.IgnoreBlank = True
.InCellDropdown = True
.InputTitle = ""
.ErrorTitle = ""
.InputMessage = ""
.ErrorMessage = ""
.ShowInput = True
.ShowError = True
.Parent.Value = WorksheetFunction.Lookup(MsgBox("Click the button that will be the default value for Column AK", vbYesNo), Array(6, 7), Array("Yes", "No"))
End With
Range("AL2:AL" & LR).Validation
.Delete
.Add Type:=xlValidateList, AlertStyle:=xlValidAlertStop, Operator:=xlBetween, Formula1:="Yes, No"
.IgnoreBlank = True
.InCellDropdown = True
.InputTitle = ""
.ErrorTitle = ""
.InputMessage = ""
.ErrorMessage = ""
.ShowInput = True
.ShowError = True
.Parent.Value = WorksheetFunction.Lookup(MsgBox("Click the button that will be the default value for Column AL", vbYesNo), Array(6, 7), Array("Yes", "No"))
End With
Range("AP2:AP" & LR).Validation
.Delete
.Add Type:=xlValidateList, AlertStyle:=xlValidAlertStop, Operator:=xlBetween, Formula1:="Deals, Offer, Merchant Coupon"
.IgnoreBlank = True
.InCellDropdown = True
.InputTitle = ""
.ErrorTitle = ""
.InputMessage = ""
.ErrorMessage = ""
.ShowInput = True
.ShowError = True
.Parent.Value = WorksheetFunction.Lookup(MsgBox("Click the button that will be the default value for Column P" _
& vbLf & vbLf & "Yes = 'Deals'" & vbLf & "No = 'Offer'" & vbLf & "Cancel = 'Merchant Coupon'", vbYesNoCancel, "Choose"), _
Array(2, 6, 7), Array("Merchant Coupon", "Deals", "Offer"))
End With
End Sub
OK; so this is what I have done, I will try it but, I don't think it's going to work.
There are currently 1 users browsing this thread. (0 members and 1 guests)
Bookmarks