VBA CHALLENGE FOR EXPERTS

NeoSez

Board Regular
Joined
Aug 14, 2020
Messages
210
Office Version
  1. 2019
  2. 2010
Platform
  1. Windows
I am still a beginner with VBA.
I have been playing with the same spreadsheet trying to learn.
New Challenge: copying from another sheet and another Workbook
See Conditions below.
Can it be done? If so, how? Thank you.

WB1 Sheet2 Column F --> Sheet1 Column A (Any new data based on these 2 columns data should be adding entire row to Sheet1 after last used row)
WB1 Sheet2 Column X --> Sheet1 Column C
WB1 Sheet2 Column L --> Sheet1 Column F
WB1 Sheet2 Column T --> Sheet1 Column I (overwrite Sh1 Col.I contents)
EXTRACT Date ONLY (MM/DD/YYYY) from Sheet2 Column T-->Sheet1 Column G
WB1 Sheet2 Column F --> Sheet1 Column A
Workbook2 Sheet1 Column AR--> Sheet1 Column K (must copy hyperlink to photo)
 

Excel Facts

How can you turn a range sideways?
Copy the range. Select a blank cell. Right-click, Paste Special, then choose Transpose.
i don't understand what your arrows mean in the OP.
In words, what do you want copied from where to where? Is this controled by calling a macro or pressing a button or what?
You said that you had some code. What is that code and what is is not doing right?
 
Upvote 0
i don't understand what your arrows mean in the OP.
In words, what do you want copied from where to where? Is this controled by calling a macro or pressing a button or what?
You said that you had some code. What is that code and what is is not doing right?
Hello mikerickson. Thank you replying to my post.
Yes, it would be controlled by clicking on a button assigned to a macro.
The arrows mean copy to.
Workbook1 Sheet2 Column F copy to Sheet1 Column A (Any new data based on these 2 columns data should be adding entire row to Sheet1 after last used row)
WB1 Sheet2 Column X copy to Sheet1 Column C
WB1 Sheet2 Column L copy to Sheet1 Column F
WB1 Sheet2 Column T copy to Sheet1 Column I (overwrite Sh1 Col.I contents)
EXTRACT Date ONLY (MM/DD/YYYY) from Sheet2 Column T copy to Sheet1 Column G
WB1 Sheet2 Column F copy to Sheet1 Column A
Workbook2 Sheet1 Column AR copy to Sheet1 Column K (must copy hyperlink to photo)

Yes, I have some code that would not paste the hyperlinks properly. I found a few codes on the internet but none worked, so I got rid of them.
I don't know how to write the code for most of it.
I think I have these two figured out.
WB1 Sheet2 Column X copy to Sheet1 Column C
WB1 Sheet2 Column L copy to Sheet1 Column F

So I found this code on the internet and tried to modify it to work for me, but not sure how to modify it to suit my needs.
Is it possible to put multiple macros under one button?

VBA Code:
Sub copycolumns()

Dim lastrow As Long, erow As Long
lastrow = Sheet1.Cells(Rows.Count, 1).End(xlUp).Row

For i = 2 To lastrow
If Sheet1.Cells(i, 6) = “Maharashtra” Then
Sheet1.Cells(i, 1).Copy
erow = Sheet2.Cells(Rows.Count, 1).End(xlUp).Offset(1, 0).Row
Sheet1.Paste Destination:=Worksheets(“Sheet2”).Cells(erow, 1)

Sheet1.Cells(i, 3).Copy
Sheet1.Paste Destination:=Worksheets(“Sheet2”).Cells(erow, 2)

Sheet1.Cells(i, 6).Copy
Sheet1.Paste Destination:=Worksheets(“Sheet2”).Cells(erow, 3)
End If

Next i
Application.CutCopyMode = False
Sheet2.Columns().AutoFit
Range(“A1”).Select

End Sub
 
Upvote 0

Forum statistics

Threads
1,215,059
Messages
6,122,918
Members
449,093
Latest member
dbomb1414

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