Microsoft Office Forums

Go Back   Microsoft Office Forums > >

Reply
 
Thread Tools Display Modes
  #1  
Old 08-27-2020, 08:09 AM
mthwi mthwi is offline Insert a new Column a in specific Sheet and fill it with content Windows 10 Insert a new Column a in specific Sheet and fill it with content Office 2016
Novice
Insert a new Column a in specific Sheet and fill it with content
 
Join Date: Nov 2017
Posts: 5
mthwi is on a distinguished road
Default Insert a new Column a in specific Sheet and fill it with content


Hi,
i have the following code and it does not work.
I want to select the sheet with the first input box and with the 2. the value to be entered in the new column 'A'.

Maybe someone can correct the code.

Here is the code:
Code:
Sub Einfügen_New_A_and_Fill_with_Content_SPECIFIC_SHEET()
Dim ws As Worksheet, Data$
ws = InputBox("Provide a sheet name:")
Data = InputBox("What would you like to insert in column A ?")
For Each ws In Sheets
   ws.Columns(1).Insert
   ws.Cells(1).Resize(ws.UsedRange.Rows.Count) = Data
Next
End Sub
Vielen Dank
Reply With Quote
  #2  
Old 08-27-2020, 11:46 AM
Logit Logit is offline Insert a new Column a in specific Sheet and fill it with content Windows 10 Insert a new Column a in specific Sheet and fill it with content Office 2007
Expert
 
Join Date: Jan 2017
Posts: 529
Logit is a jewel in the roughLogit is a jewel in the roughLogit is a jewel in the rough
Default

See if this works :

Code:
Option Explicit

Sub Einfügen_New_A_and_Fill_with_Content_SPECIFIC_SHEET()
Dim Data As String
Dim Result As String

Result = InputBox("Provide a sheet name.")
ThisWorkbook.Sheets(Result).Activate

Data = InputBox("What would you like to insert in column A ?")

   ActiveSheet.Cells(1).Resize(ActiveSheet.UsedRange.Rows.Count) = Data

End Sub
Reply With Quote
  #3  
Old 08-27-2020, 11:53 AM
Purfleet Purfleet is offline Insert a new Column a in specific Sheet and fill it with content Windows 10 Insert a new Column a in specific Sheet and fill it with content Office 2019
Expert
 
Join Date: Jun 2020
Location: Essex
Posts: 345
Purfleet is a splendid one to beholdPurfleet is a splendid one to beholdPurfleet is a splendid one to beholdPurfleet is a splendid one to beholdPurfleet is a splendid one to beholdPurfleet is a splendid one to beholdPurfleet is a splendid one to behold
Default

Pretty sure you cant have ws defined as a worksheet and assign a string to it.

If you change Dim ws as worksheet to Dim ws as variant it works

Code:
Sub Einfügen_New_A_and_Fill_with_Content_SPECIFIC_SHEET()
 Dim ws As Variant, Data$
ws = InputBox("Provide a sheet name:")
Data = InputBox("What would you like to insert in column A ?")
For Each ws In Sheets
   ws.Columns(1).Insert
   ws.Cells(1).Resize(ws.UsedRange.Rows.Count) = Data
Next
End Sub
Reply With Quote
  #4  
Old 08-28-2020, 05:09 AM
mthwi mthwi is offline Insert a new Column a in specific Sheet and fill it with content Windows 10 Insert a new Column a in specific Sheet and fill it with content Office 2016
Novice
Insert a new Column a in specific Sheet and fill it with content
 
Join Date: Nov 2017
Posts: 5
mthwi is on a distinguished road
Default

Sorry for the late reply.
Thank you very, very much.
It works like a charm.
Reply With Quote
Reply

Thread Tools
Display Modes


Similar Threads
Thread Thread Starter Forum Replies Last Post
Insert a new Column a in specific Sheet and fill it with content Insert Rich Text Content Control in specific position, Word 2013 VBA LaurenM Word VBA 13 12-01-2017 02:07 AM
Insert a new Column a in specific Sheet and fill it with content Export Word Drop-Down Content Control to Excel Specific Sheet nolanthomas32 Word VBA 4 09-19-2017 06:25 AM
Insert a new Column a in specific Sheet and fill it with content Code to Sum Column of Content Control Values In Specific Tables? warbird Word VBA 2 07-13-2015 05:44 AM
Excel copy two numbers between specific column and paste in next sheet visha_1984 Excel 1 12-26-2014 07:59 PM
Insert a new Column a in specific Sheet and fill it with content Create a New Sheet from Existing Sheet with Specific Columns malam Excel Programming 1 10-17-2014 10:01 PM

Other Forums: Access Forums

All times are GMT -7. The time now is 04:57 AM.


Powered by vBulletin® Version 3.8.11
Copyright ©2000 - 2024, vBulletin Solutions Inc.
Search Engine Optimisation provided by DragonByte SEO (Lite) - vBulletin Mods & Addons Copyright © 2024 DragonByte Technologies Ltd.
MSOfficeForums.com is not affiliated with Microsoft