Need help with VBA coding

TannerLittle44

New Member
Joined
Aug 14, 2015
Messages
4
I cant figure out whats wrong with my coding. I get an error message every time the code reaches the Bold Red txt shown below, If any of you can see something that i am not catching please let me know. The error message states "1004" Run Time Error, Application-defined Object-defined Error.

Thanks,




Sub Update_DC_Inventory()




Application.ScreenUpdating = False 'Code eliminates screen flashing. Macro will run in backgroud
Dim wbTarget As Workbook 'workbook where the data is to be pasted
Dim wbThis As Workbook 'workbook from where the data is to copied
Dim strName As String 'name of the source sheet/ target workbook
'On Error GoTo ErrorHandler
'set to the current active workbook (the source book)
Set wbThis = ActiveWorkbook


'open a workbook that has same name as the sheet name
Set wbTarget = Workbooks.Open("G:\1Marketing\_Marketing Event Orders\Inventory 2015.xlsm")

'select cell A1 on the target book
wbTarget.Sheets("Promo").Activate
'The code below is for after paste file has been opened.
Range("H1").End(xlToRight).Offset(0, 1).Select
'activate the source book
wbThis.Activate

'clear any thing on clipboard to maximize available memory
Application.CutCopyMode = False
wbThis.Sheets("Data").Select
'copy the range from source book
wbThis.Sheets("Data").Range("T1:T86").Select
Selection.Copy


wbTarget.Activate

Selection.PasteSpecial xlPasteValuesAndNumberFormats
Selection.PasteSpecial xlPasteFormats, Operation:=xlNone, SkipBlanks:=False, Transpose:=False

wbThis.Activate

wbThis.Sheets("Event Order Form").Select

Call Submit_Order_Form

MsgBox "Event Order Form has been submitted to DC Marketing"

wbTarget.Activate

'wbTarget.Sheets("Reorder Email Template").Select

Call Find_First



End Sub
 

Excel Facts

Can Excel fill bagel flavors?
You can teach Excel a new custom list. Type the list in cells, File, Options, Advanced, Edit Custom Lists, Import, OK
What data is on row 1?

What are you trying to do here anyway?
Code:
Range("H1").End(xlToRight).Offset(0, 1).Select
I think you are trying to find the last column in row 1 but you don't seem to do anything other than that.
 
Upvote 0
It looks like Range("H1").End(xlToRight) puts you on last cell of line 1 and you try then to do an offset so error. Can it be that sometimes you have nothing at the right of H1? or you have data in last cell of row 1?
 
Upvote 0

Forum statistics

Threads
1,223,270
Messages
6,171,102
Members
452,379
Latest member
IainTru

We've detected that you are using an adblocker.

We have a great community of people providing Excel help here, but the hosting costs are enormous. You can help keep this site running by allowing ads on MrExcel.com.
Allow Ads at MrExcel

Which adblocker are you using?

Disable AdBlock

Follow these easy steps to disable AdBlock

1)Click on the icon in the browser’s toolbar.
2)Click on the icon in the browser’s toolbar.
2)Click on the "Pause on this site" option.
Go back

Disable AdBlock Plus

Follow these easy steps to disable AdBlock Plus

1)Click on the icon in the browser’s toolbar.
2)Click on the toggle to disable it for "mrexcel.com".
Go back

Disable uBlock Origin

Follow these easy steps to disable uBlock Origin

1)Click on the icon in the browser’s toolbar.
2)Click on the "Power" button.
3)Click on the "Refresh" button.
Go back

Disable uBlock

Follow these easy steps to disable uBlock

1)Click on the icon in the browser’s toolbar.
2)Click on the "Power" button.
3)Click on the "Refresh" button.
Go back
Back
Top