Replace values in a specific column and row VBA

Tresor

New Member
Joined
Dec 21, 2020
Messages
2
Office Version
  1. 365
Platform
  1. Windows
Hello everyone!

Hope you are great.

I am trying (with no success) to filter for a specific value in a table and replace the column number 4 with the data in a differen sheet. I copy all the data in the first row and I don´t know how to paste it in the specific row. The code that I am using is the following:

VBA Code:
Sub copia()
    
    Application.ScreenUpdating = False
    
    Dim hotel As String
    
    hotel = ActiveSheet.Name
         
    Sheets("discounts").Select
    ActiveSheet.ListObjects("discount").Range.AutoFilter Field:=1, Criteria1:=hotel
    
    Sheets(hotel).Select
    Range("d43:d50").Select
    Selection.Copy
    
    Sheets("discounts").Select
    ActiveSheet.ListObjects("discount").ListColumns(4).Range.Select
    Selection.PasteSpecial Paste:=xlPasteValues, Operation:=xlNone, SkipBlanks:=False, Transpose:=False
    
    Sheets(hotel).Select
    Range("L33").Select
    
    Application.CutCopyMode = False
    
End Sub

All the help will be apreciate.

Thanks!
 

Excel Facts

How to show all formulas in Excel?
Press Ctrl+` to show all formulas. Press it again to toggle back to numbers. The grave accent is often under the tilde on US keyboards.
If this does not work like you want, try redording it.

VBA Code:
Sub copia()    
    Application.ScreenUpdating = False    
    Dim hotel As String    
    hotel = ActiveSheet.Name         
    Sheets("discounts").ListObjects("discount").Range.AutoFilter Field:=1, Criteria1:=hotel    
    Sheets(hotel).Range("d43:d50").Copy    
    Sheets("discounts").ListObjects("discount").Cells(1. 4).PasteSpecial Paste:=xlPasteValues, _
    Operation:=xlNone, SkipBlanks:=False, Transpose:=False
    Sheets(hotel).Select
    Range("L33").Select    
    Application.CutCopyMode = False    
End Sub
 
Upvote 0
If this does not work like you want, try redording it.

VBA Code:
Sub copia()   
    Application.ScreenUpdating = False   
    Dim hotel As String   
    hotel = ActiveSheet.Name        
    Sheets("discounts").ListObjects("discount").Range.AutoFilter Field:=1, Criteria1:=hotel   
    Sheets(hotel).Range("d43:d50").Copy   
    Sheets("discounts").ListObjects("discount").Cells(1. 4).PasteSpecial Paste:=xlPasteValues, _
    Operation:=xlNone, SkipBlanks:=False, Transpose:=False
    Sheets(hotel).Select
    Range("L33").Select   
    Application.CutCopyMode = False   
End Sub
Good morning,

thanks for the answer.

Unfortunately it doesn´t work :(
 
Upvote 0

Forum statistics

Threads
1,214,651
Messages
6,120,742
Members
448,989
Latest member
mariah3

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