Avoiding copy/paste, selection to transfer data in VBA

ItalianPlatinum

Well-known Member
Joined
Mar 23, 2017
Messages
857
Office Version
  1. 365
  2. 2019
Platform
  1. Windows
Looking for a way to transfer a set of data over to another sheet after i set a filter without copy, selecting or pasting.
  1. Sheet 1: filtered to not show blanks
    1. Want to transfer the data left showing
  2. Sheet 2: Where I want to transfer the data to
  3. Columns match up like this:
    1. Column A to Column A13 down
    2. Column I to Column B13 down
    3. Column J to Column C13 down
    4. so on and so on.....
 
I think the
VBA Code:
("A" & nr)
is suppose to be
VBA Code:
("A" & nrDist)
right?
Yes, I have edited to correct that now. Thanks for picking that up.

Below looks like it would work but i get runtime 1004 at here
If k=0 then the problem is occurring before this line of code. Looks like below would be an issue
VBA Code:
If UCase(vRows(i, 1)) = "Yes" Then
.
That will never be true. It would need to be
Rich (BB code):
If UCase(vRows(i, 1)) = "YES" Then
 
Upvote 0

Excel Facts

When they said...
When they said you are going to "Excel at life", they meant you "will be doing Excel your whole life".
Interesting didn't realize Yes vs YES was that significant. I have made that change. if the column is True/False will YES still work or should I put it as TRUE? I am getting the same error message at same spot I hope having blank data in those columns are not interfering here?
 
Upvote 0
means upper case vRows(i, 1) :)
😯

i am curious how this satifies. even though YES and TRUE are different they interact the same? does the opposite of NO and FALSE also apply?
VBA Code:
If vRows(i, 1) And UCase(vRows(i, 2)) = "YES" Then
 
Upvote 0
even though YES and TRUE are different they interact the same?
I think that you are misunderstanding the syntax
If vRows(i, 1) And UCase(vRows(i, 2)) = "YES" Then
is the same as
If vRows(i, 1) = TRUE And UCase(vRows(i, 2)) = "YES" Then
Both the red part and the blue part have to individually evaluate to TRUE for the code to proceed to whatever follows in the next line.

However, since vRows(i,1) is a logical value of TRUE or FALSE it is pointless the red part above saying
If TRUE = TRUE then TRUE
or
If FALSE = TRUE then FALSE
since the final bold result is identical to the initial bold value, which is the value already held in vRows(i,1)
 
Upvote 0
So that was very helpful it made me realize i was failing on the 2nd iteration of code because i was doing this:
VBA Code:
If (vRows1(ii, 1)) = "TRUE" Then

when in reality it should be something like this as its already a logical value
VBA Code:
If (vRows1(ii, 1)) Then
 
Upvote 0

Forum statistics

Threads
1,223,898
Messages
6,175,272
Members
452,628
Latest member
dd2

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